feat/ocw/bookkeeping (#5200)

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
Bernhard Schuster
2020-04-24 16:46:19 +02:00
committed by GitHub
parent f66168505b
commit 72ee7d5797
40 changed files with 675 additions and 80 deletions
@@ -407,6 +407,7 @@ fn generate_call_api_at_calls(decl: &ItemTrait) -> Result<TokenStream> {
at: &#crate_::BlockId<Block>,
args: Vec<u8>,
changes: &std::cell::RefCell<#crate_::OverlayedChanges>,
offchain_changes: &std::cell::RefCell<#crate_::OffchainOverlayedChanges>,
storage_transaction_cache: &std::cell::RefCell<
#crate_::StorageTransactionCache<Block, T::StateBackend>
>,
@@ -436,6 +437,7 @@ fn generate_call_api_at_calls(decl: &ItemTrait) -> Result<TokenStream> {
native_call: None,
arguments: args,
overlayed_changes: changes,
offchain_changes,
storage_transaction_cache,
initialize_block,
context,
@@ -456,6 +458,7 @@ fn generate_call_api_at_calls(decl: &ItemTrait) -> Result<TokenStream> {
native_call,
arguments: args,
overlayed_changes: changes,
offchain_changes,
storage_transaction_cache,
initialize_block,
context,
@@ -207,6 +207,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
commit_on_success: std::cell::RefCell<bool>,
initialized_block: std::cell::RefCell<Option<#crate_::BlockId<Block>>>,
changes: std::cell::RefCell<#crate_::OverlayedChanges>,
offchain_changes: std::cell::RefCell<#crate_::OffchainOverlayedChanges>,
storage_transaction_cache: std::cell::RefCell<
#crate_::StorageTransactionCache<Block, C::StateBackend>
>,
@@ -335,6 +336,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
commit_on_success: true.into(),
initialized_block: None.into(),
changes: Default::default(),
offchain_changes: Default::default(),
recorder: Default::default(),
storage_transaction_cache: Default::default(),
}.into()
@@ -353,6 +355,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
&C,
&Self,
&std::cell::RefCell<#crate_::OverlayedChanges>,
&std::cell::RefCell<#crate_::OffchainOverlayedChanges>,
&std::cell::RefCell<#crate_::StorageTransactionCache<Block, C::StateBackend>>,
&std::cell::RefCell<Option<#crate_::BlockId<Block>>>,
&Option<#crate_::ProofRecorder<Block>>,
@@ -366,6 +369,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
&self.call,
self,
&self.changes,
&self.offchain_changes,
&self.storage_transaction_cache,
&self.initialized_block,
&self.recorder,
@@ -517,6 +521,7 @@ impl<'a> Fold for ApiRuntimeImplToApiRuntimeApiImpl<'a> {
call_runtime_at,
core_api,
changes,
offchain_changes,
storage_transaction_cache,
initialized_block,
recorder
@@ -527,6 +532,7 @@ impl<'a> Fold for ApiRuntimeImplToApiRuntimeApiImpl<'a> {
at,
params_encoded,
changes,
offchain_changes,
storage_transaction_cache,
initialized_block,
params.map(|p| {
+6
View File
@@ -27,6 +27,8 @@
//!
//! Besides the macros and the [`Core`] runtime api, this crates provides the [`Metadata`] runtime
//! api, the [`ApiExt`] trait, the [`CallApiAt`] trait and the [`ConstructRuntimeApi`] trait.
//!
//! On a meta level this implies, the client calls the generated API from the client perspective.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -44,6 +46,8 @@ pub use sp_core::NativeOrEncoded;
#[doc(hidden)]
#[cfg(feature = "std")]
pub use hash_db::Hasher;
#[cfg(feature = "std")]
pub use sp_core::offchain::storage::OffchainOverlayedChanges;
#[doc(hidden)]
#[cfg(not(feature = "std"))]
pub use sp_core::to_substrate_wasm_fn_return_value;
@@ -431,6 +435,8 @@ pub struct CallApiAtParams<'a, Block: BlockT, C, NC, Backend: StateBackend<HashF
pub arguments: Vec<u8>,
/// The overlayed changes that are on top of the state.
pub overlayed_changes: &'a RefCell<OverlayedChanges>,
/// The overlayed changes to be applied to the offchain worker database.
pub offchain_changes: &'a RefCell<OffchainOverlayedChanges>,
/// The cache for storage transactions.
pub storage_transaction_cache: &'a RefCell<StorageTransactionCache<Block, Backend>>,
/// Determines if the function requires that `initialize_block` should be called before calling