Use header cache when creating state. (#5868)

* Use header cache for state_at

* Fixed warnings

* Update client/db/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Arkadiy Paronyan
2020-05-04 15:47:23 +02:00
committed by GitHub
parent e5163380e7
commit 4151dc6bfe
4 changed files with 52 additions and 28 deletions
@@ -265,6 +265,8 @@ pub struct CachedHeaderMetadata<Block: BlockT> {
pub number: NumberFor<Block>,
/// Hash of parent header.
pub parent: Block::Hash,
/// Block state root.
pub state_root: Block::Hash,
/// Hash of an ancestor header. Used to jump through the tree.
ancestor: Block::Hash,
}
@@ -275,6 +277,7 @@ impl<Block: BlockT> From<&Block::Header> for CachedHeaderMetadata<Block> {
hash: header.hash().clone(),
number: header.number().clone(),
parent: header.parent_hash().clone(),
state_root: header.state_root().clone(),
ancestor: header.parent_hash().clone(),
}
}