mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
perf: make truncate_pool no-op if pending is under limits (#6706)
This commit is contained in:
@ -455,13 +455,19 @@ impl<T: TransactionOrdering> PendingPool<T> {
|
||||
limit: SubPoolLimit,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
let mut removed = Vec::new();
|
||||
self.remove_to_limit(&limit, false, &mut removed);
|
||||
|
||||
// return early if the pool is already under the limits
|
||||
if !limit.is_exceeded(self.len(), self.size()) {
|
||||
return removed
|
||||
}
|
||||
|
||||
// now repeat for local transactions
|
||||
// first truncate only non-local transactions, returning if the pool end up under the limit
|
||||
self.remove_to_limit(&limit, false, &mut removed);
|
||||
if !limit.is_exceeded(self.len(), self.size()) {
|
||||
return removed
|
||||
}
|
||||
|
||||
// now repeat for local transactions, since local transactions must be removed now for the
|
||||
// pool to be under the limit
|
||||
self.remove_to_limit(&limit, true, &mut removed);
|
||||
|
||||
removed
|
||||
|
||||
Reference in New Issue
Block a user