Changes tries: support forks (#950)

* forks support in changes trie storage

* moved convert_hash to primitives

* optimize ChangesTrieRootsStorage::root when anchor is canonicalized
This commit is contained in:
Svyatoslav Nikolsky
2018-11-13 14:17:14 +03:00
committed by Gav Wood
parent 037f9dde10
commit 6e3c56c135
25 changed files with 276 additions and 138 deletions
+3 -3
View File
@@ -276,7 +276,7 @@ pub trait Hash: 'static + MaybeSerializeDebug + Clone + Eq + PartialEq { // Stup
fn storage_root() -> Self::Output;
/// Acquire the global storage changes root.
fn storage_changes_root(block: u64) -> Option<Self::Output>;
fn storage_changes_root(parent_hash: Self::Output, parent_number: u64) -> Option<Self::Output>;
}
/// Blake2-256 Hash implementation.
@@ -308,8 +308,8 @@ impl Hash for BlakeTwo256 {
fn storage_root() -> Self::Output {
runtime_io::storage_root().into()
}
fn storage_changes_root(block: u64) -> Option<Self::Output> {
runtime_io::storage_changes_root(block).map(Into::into)
fn storage_changes_root(parent_hash: Self::Output, parent_number: u64) -> Option<Self::Output> {
runtime_io::storage_changes_root(parent_hash.into(), parent_number).map(Into::into)
}
}