mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(pending-pool): remove unused all txs (#12777)
This commit is contained in:
@ -8,7 +8,7 @@ use crate::{
|
||||
};
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::{hash_map::Entry, BTreeMap, BTreeSet, HashMap},
|
||||
collections::{hash_map::Entry, BTreeMap, HashMap},
|
||||
ops::Bound::Unbounded,
|
||||
sync::Arc,
|
||||
};
|
||||
@ -34,8 +34,6 @@ pub struct PendingPool<T: TransactionOrdering> {
|
||||
submission_id: u64,
|
||||
/// _All_ Transactions that are currently inside the pool grouped by their identifier.
|
||||
by_id: BTreeMap<TransactionId, PendingTransaction<T>>,
|
||||
/// _All_ transactions sorted by priority
|
||||
all: BTreeSet<PendingTransaction<T>>,
|
||||
/// The highest nonce transactions for each sender - like the `independent` set, but the
|
||||
/// highest instead of lowest nonce.
|
||||
highest_nonces: HashMap<SenderId, PendingTransaction<T>>,
|
||||
@ -61,7 +59,6 @@ impl<T: TransactionOrdering> PendingPool<T> {
|
||||
ordering,
|
||||
submission_id: 0,
|
||||
by_id: Default::default(),
|
||||
all: Default::default(),
|
||||
independent_transactions: Default::default(),
|
||||
highest_nonces: Default::default(),
|
||||
size_of: Default::default(),
|
||||
@ -78,7 +75,6 @@ impl<T: TransactionOrdering> PendingPool<T> {
|
||||
fn clear_transactions(&mut self) -> BTreeMap<TransactionId, PendingTransaction<T>> {
|
||||
self.independent_transactions.clear();
|
||||
self.highest_nonces.clear();
|
||||
self.all.clear();
|
||||
self.size_of.reset();
|
||||
std::mem::take(&mut self.by_id)
|
||||
}
|
||||
@ -194,7 +190,6 @@ impl<T: TransactionOrdering> PendingPool<T> {
|
||||
} else {
|
||||
self.size_of += tx.transaction.size();
|
||||
self.update_independents_and_highest_nonces(&tx);
|
||||
self.all.insert(tx.clone());
|
||||
self.by_id.insert(id, tx);
|
||||
}
|
||||
}
|
||||
@ -240,7 +235,6 @@ impl<T: TransactionOrdering> PendingPool<T> {
|
||||
|
||||
self.size_of += tx.transaction.size();
|
||||
self.update_independents_and_highest_nonces(&tx);
|
||||
self.all.insert(tx.clone());
|
||||
self.by_id.insert(id, tx);
|
||||
}
|
||||
}
|
||||
@ -307,7 +301,6 @@ impl<T: TransactionOrdering> PendingPool<T> {
|
||||
let tx = PendingTransaction { submission_id, transaction: tx, priority };
|
||||
|
||||
self.update_independents_and_highest_nonces(&tx);
|
||||
self.all.insert(tx.clone());
|
||||
|
||||
// send the new transaction to any existing pendingpool static file iterators
|
||||
if self.new_transaction_notifier.receiver_count() > 0 {
|
||||
@ -337,7 +330,6 @@ impl<T: TransactionOrdering> PendingPool<T> {
|
||||
|
||||
let tx = self.by_id.remove(id)?;
|
||||
self.size_of -= tx.transaction.size();
|
||||
self.all.remove(&tx);
|
||||
|
||||
if let Some(highest) = self.highest_nonces.get(&id.sender) {
|
||||
if highest.transaction.nonce() == id.nonce {
|
||||
@ -538,13 +530,12 @@ impl<T: TransactionOrdering> PendingPool<T> {
|
||||
/// Asserts that the bijection between `by_id` and `all` is valid.
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
pub(crate) fn assert_invariants(&self) {
|
||||
assert_eq!(self.by_id.len(), self.all.len(), "by_id.len() != all.len()");
|
||||
assert!(
|
||||
self.independent_transactions.len() <= self.all.len(),
|
||||
self.independent_transactions.len() <= self.by_id.len(),
|
||||
"independent.len() > all.len()"
|
||||
);
|
||||
assert!(
|
||||
self.highest_nonces.len() <= self.all.len(),
|
||||
self.highest_nonces.len() <= self.by_id.len(),
|
||||
"independent_descendants.len() > all.len()"
|
||||
);
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user