Skip to content

Commit

Permalink
touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jul 23, 2024
1 parent d74e3fe commit a843d38
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
6 changes: 5 additions & 1 deletion crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,11 @@ impl NodeConfig {
}

#[must_use]
pub fn with_mixed_mining<D: Into<Duration>>(mut self, mixed_mining: bool, block_time: Option<D>) -> Self {
pub fn with_mixed_mining<D: Into<Duration>>(
mut self,
mixed_mining: bool,
block_time: Option<D>,
) -> Self {
self.block_time = block_time.map(Into::into);
self.mixed_mining = mixed_mining;
self
Expand Down
17 changes: 9 additions & 8 deletions crates/anvil/src/eth/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use futures::{
};
use parking_lot::{lock_api::RwLockWriteGuard, RawRwLock, RwLock};
use std::{
collections::BTreeSet,
fmt,
pin::Pin,
sync::Arc,
Expand Down Expand Up @@ -175,18 +174,20 @@ impl MiningMode {
match (auto_txs, fixed_txs) {
// Both auto and fixed transactions are ready, combine them
(Poll::Ready(mut auto_txs), Poll::Ready(fixed_txs)) => {
auto_txs.extend(fixed_txs);

#[allow(clippy::mutable_key_type)]
let unique_txs: BTreeSet<_> = auto_txs.into_iter().collect();

Poll::Ready(unique_txs.into_iter().collect())
for tx in fixed_txs {
// filter unique transactions
if auto_txs.iter().any(|auto_tx| auto_tx.hash() == tx.hash()) {
continue;
}
auto_txs.push(tx);
}
Poll::Ready(auto_txs)
}
// Only auto transactions are ready, return them
(Poll::Ready(auto_txs), Poll::Pending) => Poll::Ready(auto_txs),
// Only fixed transactions are ready or both are pending,
// return fixed transactions or pending status
(_, fixed_txs) => fixed_txs,
(Poll::Pending, fixed_txs) => fixed_txs,
}
}
}
Expand Down
12 changes: 0 additions & 12 deletions crates/anvil/src/eth/pool/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ impl fmt::Debug for PoolTransaction {
}
}

impl PartialOrd for PoolTransaction {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl Ord for PoolTransaction {
fn cmp(&self, other: &Self) -> Ordering {
self.hash().cmp(&other.hash())
}
}

impl TryFrom<RpcTransaction> for PoolTransaction {
type Error = eyre::Error;
fn try_from(transaction: RpcTransaction) -> Result<Self, Self::Error> {
Expand Down

0 comments on commit a843d38

Please sign in to comment.