mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 23:37:56 +00:00
More robust state pinning (#3355)
* Better state pinning * Fixed pinning race * Update core/state-db/src/noncanonical.rs Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
@@ -92,9 +92,6 @@ pub struct RefTrackingState<Block: BlockT> {
|
||||
|
||||
impl<B: BlockT> RefTrackingState<B> {
|
||||
fn new(state: DbState, storage: Arc<StorageDb<B>>, parent_hash: Option<B::Hash>) -> RefTrackingState<B> {
|
||||
if let Some(hash) = &parent_hash {
|
||||
storage.state_db.pin(hash);
|
||||
}
|
||||
RefTrackingState {
|
||||
state,
|
||||
parent_hash,
|
||||
@@ -1401,7 +1398,7 @@ impl<Block> client::backend::Backend<Block, Blake2Hasher> for Backend<Block> whe
|
||||
match self.blockchain.header(block) {
|
||||
Ok(Some(ref hdr)) => {
|
||||
let hash = hdr.hash();
|
||||
if !self.storage.state_db.is_pruned(&hash, (*hdr.number()).saturated_into::<u64>()) {
|
||||
if let Ok(()) = self.storage.state_db.pin(&hash) {
|
||||
let root = H256::from_slice(hdr.state_root().as_ref());
|
||||
let db_state = DbState::new(self.storage.clone(), root);
|
||||
let state = RefTrackingState::new(db_state, self.storage.clone(), Some(hash.clone()));
|
||||
|
||||
Reference in New Issue
Block a user