mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 21:01:05 +00:00
Added client function to delete a recent block (#8533)
* Implemented recent block removal * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -364,6 +364,17 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf> StateDbSync<Block
|
||||
}
|
||||
}
|
||||
|
||||
fn remove(&mut self, hash: &BlockHash) -> Option<CommitSet<Key>> {
|
||||
match self.mode {
|
||||
PruningMode::ArchiveAll => {
|
||||
Some(CommitSet::default())
|
||||
},
|
||||
PruningMode::ArchiveCanonical | PruningMode::Constrained(_) => {
|
||||
self.non_canonical.remove(hash)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn pin(&mut self, hash: &BlockHash) -> Result<(), PinError> {
|
||||
match self.mode {
|
||||
PruningMode::ArchiveAll => Ok(()),
|
||||
@@ -509,6 +520,12 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf> StateDb<BlockHash
|
||||
self.db.write().revert_one()
|
||||
}
|
||||
|
||||
/// Remove specified non-canonical block.
|
||||
/// Returns a database commit or `None` if not possible.
|
||||
pub fn remove(&self, hash: &BlockHash) -> Option<CommitSet<Key>> {
|
||||
self.db.write().remove(hash)
|
||||
}
|
||||
|
||||
/// Returns last finalized block number.
|
||||
pub fn best_canonical(&self) -> Option<u64> {
|
||||
return self.db.read().best_canonical()
|
||||
|
||||
Reference in New Issue
Block a user