Synchronize state cache on finalization (#3246)

* Reorg test

* Fixed informant misreporting reorgs

* Update cache when reorg is caused by applying finality

* Test for finality reorg

* Simplified test

* Typo

Co-Authored-By: André Silva <andre.beat@gmail.com>
This commit is contained in:
Arkadiy Paronyan
2019-07-30 23:07:57 +02:00
committed by André Silva
parent 1295260f2b
commit 1d5cd20c44
8 changed files with 195 additions and 61 deletions
+5 -2
View File
@@ -292,8 +292,11 @@ impl<BlockHash: Hash, Key: Hash> StateDbSync<BlockHash, Key> {
}
pub fn pin(&mut self, hash: &BlockHash) {
trace!(target: "state-db", "Pinned block: {:?}", hash);
*self.pinned.entry(hash.clone()).or_default() += 1;
let refs = self.pinned.entry(hash.clone()).or_default();
if *refs == 0 {
trace!(target: "state-db", "Pinned block: {:?}", hash);
}
*refs += 1
}
pub fn unpin(&mut self, hash: &BlockHash) {