mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +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:
@@ -283,6 +283,13 @@ extern_functions! {
|
||||
fn ext_sr25519_verify(msg_data: *const u8, msg_len: u32, sig_data: *const u8, pubkey_data: *const u8) -> u32;
|
||||
/// Note: ext_secp256k1_ecdsa_recover returns 0 if the signature is correct, nonzero otherwise.
|
||||
fn ext_secp256k1_ecdsa_recover(msg_data: *const u8, sig_data: *const u8, pubkey_data: *mut u8) -> u32;
|
||||
|
||||
//================================
|
||||
// Offchain-worker Context
|
||||
//================================
|
||||
|
||||
/// Submit extrinsic.
|
||||
fn ext_submit_extrinsic(data: *const u8, len: u32);
|
||||
}
|
||||
|
||||
/// Ensures we use the right crypto when calling into native
|
||||
@@ -594,6 +601,18 @@ pub fn secp256k1_ecdsa_recover(sig: &[u8; 65], msg: &[u8; 32]) -> Result<[u8; 64
|
||||
}
|
||||
}
|
||||
|
||||
/// Submit extrinsic from the runtime.
|
||||
///
|
||||
/// Depending on the kind of extrinsic it will either be:
|
||||
/// 1. scheduled to be included in the next produced block (inherent)
|
||||
/// 2. added to the pool and propagated (transaction)
|
||||
pub fn submit_extrinsic<T: codec::Encode>(data: &T) {
|
||||
let encoded_data = codec::Encode::encode(data);
|
||||
unsafe {
|
||||
ext_submit_extrinsic.get()(encoded_data.as_ptr(), encoded_data.len() as u32)
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for things which can be printed.
|
||||
pub trait Printable {
|
||||
fn print(self);
|
||||
|
||||
Reference in New Issue
Block a user