Add small header cache (#7516)

* Remove header query

* Header cache

* Fix potential race issue

* Simplify status query
This commit is contained in:
Arkadiy Paronyan
2020-11-26 00:07:51 +01:00
committed by GitHub
parent f590b06fab
commit 769f1981cb
3 changed files with 46 additions and 19 deletions
@@ -1159,12 +1159,12 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
/// Prepare in-memory header that is used in execution environment.
fn prepare_environment_block(&self, parent: &BlockId<Block>) -> sp_blockchain::Result<Block::Header> {
let parent_header = self.backend.blockchain().expect_header(*parent)?;
let parent_hash = self.backend.blockchain().expect_block_hash_from_id(parent)?;
Ok(<<Block as BlockT>::Header as HeaderT>::new(
self.backend.blockchain().expect_block_number_from_id(parent)? + One::one(),
Default::default(),
Default::default(),
parent_header.hash(),
parent_hash,
Default::default(),
))
}