Skip to content

Commit 41c6d4e

Browse files
committed
refactor: simplify ancestor eviction loop
1 parent 8d415f3 commit 41c6d4e

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

tx-pool/src/component/pool_map.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -617,20 +617,20 @@ impl PoolMap {
617617

618618
let mut iter = evict_candidates.iter();
619619
while ancestors_count > self.max_ancestors_count {
620-
if let Some(next_id) = iter.next() {
621-
let removed = self.remove_entry_and_descendants(next_id);
622-
for removed_id in removed.iter().map(|entry| entry.proposal_short_id()) {
623-
parents.remove(&removed_id);
624-
}
625-
ancestors_count = self
626-
.links
627-
.calc_relation_ids(parents.clone(), Relation::Parents)
628-
.len()
629-
+ 1;
630-
evicted.extend(removed);
631-
} else {
620+
let Some(next_id) = iter.next() else {
632621
break;
622+
};
623+
624+
let removed = self.remove_entry_and_descendants(next_id);
625+
for removed_id in removed.iter().map(|entry| entry.proposal_short_id()) {
626+
parents.remove(&removed_id);
633627
}
628+
ancestors_count = self
629+
.links
630+
.calc_relation_ids(parents.clone(), Relation::Parents)
631+
.len()
632+
+ 1;
633+
evicted.extend(removed);
634634
}
635635

636636
// some txs in `parents` are removed, now `ancestors` need to re-caculate,

0 commit comments

Comments
 (0)