mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 06:57:58 +00:00
Initial: Offchain Workers (#1942)
* Refactor state-machine stuff. * Fix tests. * WiP * WiP2 * Service support for offchain workers. * Service support for offchain workers. * Testing offchain worker. * Initial version working. * Pass side effects in call. * Pass OffchainExt in context. * Submit extrinsics to the pool. * Support inherents. * Insert to inherents pool. * Inserting to the pool asynchronously. * Add test to offchain worker. * Implement convenience syntax for modules. * Dispatching offchain worker through executive. * Fix offchain test. * Remove offchain worker from timestamp. * Update Cargo.lock. * Address review comments. * Use latest patch version for futures. * Add CLI parameter for offchain worker. * Fix compilation. * Fix test. * Fix extrinsics format for tests. * Fix RPC test. * Bump spec version. * Fix executive. * Fix support macro. * Address grumbles. * Bump runtime
This commit is contained in:
@@ -94,6 +94,7 @@ impl Transfer {
|
||||
pub enum Extrinsic {
|
||||
AuthoritiesChange(Vec<AuthorityId>),
|
||||
Transfer(Transfer, AccountSignature),
|
||||
IncludeData(Vec<u8>),
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
@@ -117,6 +118,7 @@ impl BlindCheckable for Extrinsic {
|
||||
Err(runtime_primitives::BAD_SIGNATURE)
|
||||
}
|
||||
},
|
||||
Extrinsic::IncludeData(data) => Ok(Extrinsic::IncludeData(data)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -377,6 +379,13 @@ cfg_if! {
|
||||
impl consensus_aura::AuraApi<Block> for Runtime {
|
||||
fn slot_duration() -> u64 { 1 }
|
||||
}
|
||||
|
||||
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(block: u64) {
|
||||
let ex = Extrinsic::IncludeData(block.encode());
|
||||
runtime_io::submit_extrinsic(&ex)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
impl_runtime_apis! {
|
||||
@@ -480,6 +489,13 @@ cfg_if! {
|
||||
impl consensus_aura::AuraApi<Block> for Runtime {
|
||||
fn slot_duration() -> u64 { 1 }
|
||||
}
|
||||
|
||||
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(block: u64) {
|
||||
let ex = Extrinsic::IncludeData(block.encode());
|
||||
runtime_io::submit_extrinsic(&ex)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,6 +242,7 @@ fn execute_transaction_backend(utx: &Extrinsic) -> ApplyResult {
|
||||
match utx {
|
||||
Extrinsic::Transfer(ref transfer, _) => execute_transfer_backend(transfer),
|
||||
Extrinsic::AuthoritiesChange(ref new_auth) => execute_new_authorities_backend(new_auth),
|
||||
Extrinsic::IncludeData(_) => Ok(ApplyOutcome::Success),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user