mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 22:41:06 +00:00
Fixed pruning detection in archive mode (#1670)
This commit is contained in:
committed by
Bastian Köcher
parent
1a3fa9eb68
commit
38d7eb66a7
@@ -231,10 +231,15 @@ impl<BlockHash: Hash, Key: Hash> StateDbSync<BlockHash, Key> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_pruned(&self, hash: &BlockHash, number: u64) -> bool {
|
pub fn is_pruned(&self, hash: &BlockHash, number: u64) -> bool {
|
||||||
if self.best_canonical().map(|c| number > c).unwrap_or(true) {
|
match self.mode {
|
||||||
!self.non_canonical.have_block(hash)
|
PruningMode::ArchiveAll => false,
|
||||||
} else {
|
PruningMode::ArchiveCanonical | PruningMode::Constrained(_) => {
|
||||||
self.pruning.as_ref().map_or(false, |pruning| number < pruning.pending() || !pruning.have_block(hash))
|
if self.best_canonical().map(|c| number > c).unwrap_or(true) {
|
||||||
|
!self.non_canonical.have_block(hash)
|
||||||
|
} else {
|
||||||
|
self.pruning.as_ref().map_or(false, |pruning| number < pruning.pending() || !pruning.have_block(hash))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,8 +456,9 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn full_archive_keeps_everything() {
|
fn full_archive_keeps_everything() {
|
||||||
let (db, _) = make_test_db(PruningMode::ArchiveAll);
|
let (db, sdb) = make_test_db(PruningMode::ArchiveAll);
|
||||||
assert!(db.data_eq(&make_db(&[1, 21, 22, 3, 4, 91, 921, 922, 93, 94])));
|
assert!(db.data_eq(&make_db(&[1, 21, 22, 3, 4, 91, 921, 922, 93, 94])));
|
||||||
|
assert!(!sdb.is_pruned(&H256::from_low_u64_be(0), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user