Make offchain indexing work (#7940)

* Make offchain indexing work

This fixes some bugs with offchain indexing to make it actually working ;)

* Fix tests

* Fix browser build

* Update client/db/src/offchain.rs

Co-authored-by: cheme <emericchevalier.pro@gmail.com>

* Remove seperation between prefix and key

Co-authored-by: cheme <emericchevalier.pro@gmail.com>
This commit is contained in:
Bastian Köcher
2021-01-21 13:12:42 +01:00
committed by GitHub
parent a3a9e7667c
commit cd0ad4805d
24 changed files with 188 additions and 306 deletions
+12 -1
View File
@@ -79,6 +79,7 @@ pub struct TestClientBuilder<Block: BlockT, Executor, Backend, G: GenesisInit> {
keystore: Option<SyncCryptoStorePtr>,
fork_blocks: ForkBlocks<Block>,
bad_blocks: BadBlocks<Block>,
enable_offchain_indexing_api: bool,
}
impl<Block: BlockT, Executor, G: GenesisInit> Default
@@ -114,6 +115,7 @@ impl<Block: BlockT, Executor, Backend, G: GenesisInit> TestClientBuilder<Block,
keystore: None,
fork_blocks: None,
bad_blocks: None,
enable_offchain_indexing_api: false,
}
}
@@ -175,6 +177,12 @@ impl<Block: BlockT, Executor, Backend, G: GenesisInit> TestClientBuilder<Block,
self
}
/// Enable the offchain indexing api.
pub fn enable_offchain_indexing_api(mut self) -> Self {
self.enable_offchain_indexing_api = true;
self
}
/// Build the test client with the given native executor.
pub fn build_with_executor<RuntimeApi>(
self,
@@ -219,7 +227,10 @@ impl<Block: BlockT, Executor, Backend, G: GenesisInit> TestClientBuilder<Block,
self.keystore,
),
None,
ClientConfig::default(),
ClientConfig {
offchain_indexing_api: self.enable_offchain_indexing_api,
..Default::default()
},
).expect("Creates new client");
let longest_chain = sc_consensus::LongestChain::new(self.backend);