mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 03:27:58 +00:00
Offchain Workers: Example Pallet (#4989)
* Example of offchain worker pallet. * Fix compilation issues. * Use serde_json to parse JSON. * Add some basic tests. * Working on docs. * Fix compilation * Finish docs for signed. * Work on unsigned send. * Add some tests and missing docs. * Add example of StorageValueRef * Add weight. * Extra \n * Fix im-online test. * Bump runtime. * Fix tests. * Apply suggestions from code review Co-Authored-By: Joshy Orndorff <JoshOrndorff@users.noreply.github.com> Co-Authored-By: Gavin Wood <gavin@parity.io> * Address review comments. Co-authored-by: Joshy Orndorff <JoshOrndorff@users.noreply.github.com> Co-authored-by: Gavin Wood <github@gavwood.com>
This commit is contained in:
@@ -72,6 +72,8 @@ pub struct OffchainState {
|
||||
pub persistent_storage: InMemOffchainStorage,
|
||||
/// Local storage
|
||||
pub local_storage: InMemOffchainStorage,
|
||||
/// Current timestamp (unix millis)
|
||||
pub timestamp: u64,
|
||||
}
|
||||
|
||||
impl OffchainState {
|
||||
@@ -144,7 +146,7 @@ impl TestOffchainExt {
|
||||
|
||||
impl offchain::Externalities for TestOffchainExt {
|
||||
fn is_validator(&self) -> bool {
|
||||
unimplemented!("not needed in tests so far")
|
||||
true
|
||||
}
|
||||
|
||||
fn network_state(&self) -> Result<OpaqueNetworkState, ()> {
|
||||
@@ -155,7 +157,7 @@ impl offchain::Externalities for TestOffchainExt {
|
||||
}
|
||||
|
||||
fn timestamp(&mut self) -> Timestamp {
|
||||
unimplemented!("not needed in tests so far")
|
||||
Timestamp::from_unix_millis(self.0.read().timestamp)
|
||||
}
|
||||
|
||||
fn sleep_until(&mut self, _deadline: Timestamp) {
|
||||
|
||||
Reference in New Issue
Block a user