mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 16:37:57 +00:00
Offchain-worker APIs stubs (#2615)
* WiP: HTTP Apis. * Working on the API. * Add docs, clean up the API. * Expose ext_ stuff as well. * Implement HTTP helpers for offchain sr-io. * Remove HTTP stuff. * Revert "Remove HTTP stuff." This reverts commit 7cca029d6ae93c5849b50edfcc6d2c313ba3e5bf. * HTTP apis. * Additional offchain methods. * Make it compile. * Implement wasm-ext boundary of offchain methods. * Add stubs for offchain stuff to prevent panics. * Fix tests. * Addres some more issues. * Introduce typedef, use unsafe from_utf8 * Bump runtime version. * Introduce error to distinguish deadline and io errors. * Add local_storage_cas * Some tests for offchain stuff. * Address more grumbles. * Fix tests compilation. * Fix borked merge. * Improve docs for expected return values from ext functions. * Adding new sign/enrypt/decrypt APIs.
This commit is contained in:
committed by
Gavin Wood
parent
80b18c8531
commit
308ab4f269
@@ -56,6 +56,7 @@ pub mod ed25519;
|
||||
pub mod sr25519;
|
||||
pub mod hash;
|
||||
mod hasher;
|
||||
pub mod offchain;
|
||||
pub mod sandbox;
|
||||
pub mod storage;
|
||||
pub mod uint;
|
||||
@@ -85,25 +86,11 @@ pub enum ExecutionContext {
|
||||
/// Context used for block construction.
|
||||
BlockConstruction,
|
||||
/// Offchain worker context.
|
||||
OffchainWorker(Box<OffchainExt>),
|
||||
OffchainWorker(Box<offchain::Externalities>),
|
||||
/// Context used for other calls.
|
||||
Other,
|
||||
}
|
||||
|
||||
/// An extended externalities for offchain workers.
|
||||
pub trait OffchainExt {
|
||||
/// Submits an extrinsics.
|
||||
///
|
||||
/// The extrinsic will either go to the pool (signed)
|
||||
/// or to the next produced block (inherent).
|
||||
fn submit_extrinsic(&mut self, extrinsic: Vec<u8>);
|
||||
}
|
||||
impl<T: OffchainExt + ?Sized> OffchainExt for Box<T> {
|
||||
fn submit_extrinsic(&mut self, ex: Vec<u8>) {
|
||||
(&mut **self).submit_extrinsic(ex)
|
||||
}
|
||||
}
|
||||
|
||||
/// Hex-serialized shim for `Vec<u8>`.
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug, Hash, PartialOrd, Ord))]
|
||||
|
||||
Reference in New Issue
Block a user