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
+9 -1
View File
@@ -19,7 +19,7 @@
use std::sync::Arc;
use std::collections::HashMap;
use sp_core::ChangesTrieConfigurationRange;
use sp_core::offchain::OffchainStorage;
use sp_core::offchain::{OffchainStorage,storage::OffchainOverlayedChanges};
use sp_runtime::{generic::BlockId, Justification, Storage};
use sp_runtime::traits::{Block as BlockT, NumberFor, HashFor};
use sp_state_machine::{
@@ -148,6 +148,14 @@ pub trait BlockImportOperation<Block: BlockT> {
child_update: ChildStorageCollection,
) -> sp_blockchain::Result<()>;
/// Write offchain storage changes to the database.
fn update_offchain_storage(
&mut self,
_offchain_update: OffchainOverlayedChanges,
) -> sp_blockchain::Result<()> {
Ok(())
}
/// Inject changes trie data into the database.
fn update_changes_trie(
&mut self,
+2 -1
View File
@@ -26,7 +26,7 @@ use sp_state_machine::{
};
use sc_executor::{RuntimeVersion, NativeVersion};
use sp_externalities::Extensions;
use sp_core::NativeOrEncoded;
use sp_core::{NativeOrEncoded,offchain::storage::OffchainOverlayedChanges};
use sp_api::{ProofRecorder, InitializeBlock, StorageTransactionCache};
use crate::execution_extensions::ExecutionExtensions;
@@ -84,6 +84,7 @@ pub trait CallExecutor<B: BlockT> {
method: &str,
call_data: &[u8],
changes: &RefCell<OverlayedChanges>,
offchain_changes: &RefCell<OffchainOverlayedChanges>,
storage_transaction_cache: Option<&RefCell<
StorageTransactionCache<B, <Self::Backend as crate::backend::Backend<B>>::State>,
>>,
@@ -177,7 +177,7 @@ impl<Block: traits::Block> ExecutionExtensions<Block> {
if let ExecutionContext::OffchainCall(Some(ext)) = context {
extensions.register(
OffchainExt::new(offchain::LimitedExternalities::new(capabilities, ext.0))
)
);
}
(manager, extensions)