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 ParonyanandAndré Silva authored and André Silva committed 2019-07-30 22:07:57 +01:00
1 parent 1295260f2b
commit 1d5cd20c44
8 files changed
+195 -61

No files matched your search

+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) {