Pin states in memory so that they are not pruned away while still referenced (#2761)

* State pinning in client

* Canonicalization queue

* Fixed prioritization queue

* possible fix of "hash mismatch"

* Check for pinned discarded states

* Release state before finalization

* Style

* Style
This commit is contained in:
Arkadiy Paronyan
2019-06-04 10:01:12 +02:00
committed by Gavin Wood
parent 6ce7c1c8c8
commit 3b26453047
13 changed files with 392 additions and 194 deletions
+4 -4
View File
@@ -101,14 +101,14 @@ pub fn build_proof<Header, Hasher, BlocksI, HashesI>(
.into_iter()
.map(|(k, v)| (None, k, Some(v)))
.collect::<Vec<_>>();
let storage = InMemoryState::<Hasher>::default().update(transaction);
let trie_storage = storage.try_into_trie_backend()
.expect("InMemoryState::try_into_trie_backend always returns Some; qed");
let mut storage = InMemoryState::<Hasher>::default().update(transaction);
let trie_storage = storage.as_trie_backend()
.expect("InMemoryState::as_trie_backend always returns Some; qed");
let mut total_proof = HashSet::new();
for block in blocks.into_iter() {
debug_assert_eq!(block_to_cht_number(cht_size, block), Some(cht_num));
let (value, proof) = prove_read_on_trie_backend(&trie_storage, &encode_cht_key(block))?;
let (value, proof) = prove_read_on_trie_backend(trie_storage, &encode_cht_key(block))?;
assert!(value.is_some(), "we have just built trie that includes the value for block");
total_proof.extend(proof);
}