Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add changes_trie_root function
  • Loading branch information
expenses committed Aug 24, 2020
commit 6d90ddd8c3d7819682fd1a01c0f0b5630bb6417d
15 changes: 9 additions & 6 deletions client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,14 @@ impl<Block: BlockT> BlockchainDb<Block> {
meta.finalized_hash = hash;
}
}

// Get block changes trie root, if available.
fn changes_trie_root(&self, block: BlockId<Block>) -> ClientResult<Option<Block::Hash>> {
self.header(block)
.map(|header| header.and_then(|header|
header.digest().log(DigestItem::as_changes_trie_root)
.cloned()))
}
}

impl<Block: BlockT> sc_client_api::blockchain::HeaderBackend<Block> for BlockchainDb<Block> {
Expand Down Expand Up @@ -572,12 +580,7 @@ impl<Block: BlockT> ProvideChtRoots<Block> for BlockchainDb<Block> {
cht::compute_root::<Block::Header, HashFor<Block>, _>(
cht::size(),
cht_number,
cht_range
.map(|num| self.header(BlockId::Number(num))
.map(|header| header.and_then(|header| {
header.digest().log(DigestItem::as_changes_trie_root).cloned()
}))
)
cht_range.map(|num| self.changes_trie_root(BlockId::Number(num))),
).map(Some)
}
}
Expand Down