Skip to content

Commit

Permalink
remove clippy allow
Browse files Browse the repository at this point in the history
  • Loading branch information
someone235 committed Aug 26, 2024
1 parent 4941a68 commit 6d6ae1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
6 changes: 2 additions & 4 deletions mining/src/mempool/model/transactions_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,12 @@ impl TransactionsPool {
let transaction_size = transaction.tx.estimate_mem_bytes();
let mut txs_to_remove = Vec::with_capacity(1);
let mut selected_size = 0;
let mut num_selected = 0;
#[allow(clippy::explicit_counter_loop)]
for tx in self
for (num_selected, tx) in self
.ready_transactions
.ascending_iter()
.map(|tx| self.all_transactions.get(&tx.id()).unwrap())
.filter(|mtx| mtx.priority == Priority::Low && !mtx.is_parent_of(transaction))
.enumerate()
{
if self.len() + 1 - num_selected <= self.config.maximum_transaction_count
&& self.estimated_size + transaction_size - selected_size <= self.config.mempool_size_limit
Expand All @@ -224,7 +223,6 @@ impl TransactionsPool {

txs_to_remove.push(tx.id());
selected_size += tx.mtx.tx.estimate_mem_bytes();
num_selected += 1;
}

Ok(txs_to_remove)
Expand Down
24 changes: 10 additions & 14 deletions mining/src/mempool/validate_and_insert_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,22 @@ impl Mempool {
// smallest prefix of `ready_transactions` (sorted by ascending fee-rate)
// that makes enough room for `transaction`, but since each call to `self.remove_transaction`
// also removes all transactions dependant on `x` we might already have enough room.
#[allow(clippy::int_plus_one)]
if self.transaction_pool.len() + 1 <= self.config.maximum_transaction_count
if self.transaction_pool.len() < self.config.maximum_transaction_count
&& self.transaction_pool.get_estimated_size() + transaction_size <= self.config.mempool_size_limit
{
break;
}
}

#[allow(clippy::int_plus_one)]
{
assert!(
self.transaction_pool.len() + 1 <= self.config.maximum_transaction_count
&& self.transaction_pool.get_estimated_size() + transaction_size <= self.config.mempool_size_limit,
"Transactions in mempool: {}, max: {}, mempool size: {}, max: {}",
self.transaction_pool.len() + 1,
self.config.maximum_transaction_count,
self.transaction_pool.get_estimated_size() + transaction_size,
self.config.mempool_size_limit,
);
}
assert!(
self.transaction_pool.len() < self.config.maximum_transaction_count
&& self.transaction_pool.get_estimated_size() + transaction_size <= self.config.mempool_size_limit,
"Transactions in mempool: {}, max: {}, mempool size: {}, max: {}",
self.transaction_pool.len() + 1,
self.config.maximum_transaction_count,
self.transaction_pool.get_estimated_size() + transaction_size,
self.config.mempool_size_limit,
);

// Add the transaction to the mempool as a MempoolTransaction and return a clone of the embedded Arc<Transaction>
let accepted_transaction =
Expand Down

0 comments on commit 6d6ae1a

Please sign in to comment.