Fix state-db pinning (#12927)

* Pin all canonicalized blocks

* Added a test

* Docs
This commit is contained in:
Arkadiy Paronyan
2022-12-14 12:03:16 +01:00
committed by GitHub
parent 09ae802f9c
commit 68096de80c
3 changed files with 58 additions and 18 deletions
+10
View File
@@ -470,6 +470,10 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDbSync<BlockHash, Key, D> {
}
}
fn sync(&mut self) {
self.non_canonical.sync();
}
pub fn get<DB: NodeDb, Q: ?Sized>(
&self,
key: &Q,
@@ -573,6 +577,12 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDb<BlockHash, Key, D> {
self.db.write().unpin(hash)
}
/// Confirm that all changes made to commit sets are on disk. Allows for temporarily pinned
/// blocks to be released.
pub fn sync(&self) {
self.db.write().sync()
}
/// Get a value from non-canonical/pruning overlay or the backing DB.
pub fn get<DB: NodeDb, Q: ?Sized>(
&self,