Skip to content

Commit 3523c8b

Browse files
committed
touchups
1 parent d74e3fe commit 3523c8b

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

crates/anvil/src/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,11 @@ impl NodeConfig {
637637
}
638638

639639
#[must_use]
640-
pub fn with_mixed_mining<D: Into<Duration>>(mut self, mixed_mining: bool, block_time: Option<D>) -> Self {
640+
pub fn with_mixed_mining<D: Into<Duration>>(
641+
mut self,
642+
mixed_mining: bool,
643+
block_time: Option<D>,
644+
) -> Self {
641645
self.block_time = block_time.map(Into::into);
642646
self.mixed_mining = mixed_mining;
643647
self

crates/anvil/src/eth/miner.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use futures::{
99
};
1010
use parking_lot::{lock_api::RwLockWriteGuard, RawRwLock, RwLock};
1111
use std::{
12-
collections::BTreeSet,
1312
fmt,
1413
pin::Pin,
1514
sync::Arc,
@@ -175,18 +174,20 @@ impl MiningMode {
175174
match (auto_txs, fixed_txs) {
176175
// Both auto and fixed transactions are ready, combine them
177176
(Poll::Ready(mut auto_txs), Poll::Ready(fixed_txs)) => {
178-
auto_txs.extend(fixed_txs);
179-
180-
#[allow(clippy::mutable_key_type)]
181-
let unique_txs: BTreeSet<_> = auto_txs.into_iter().collect();
182-
183-
Poll::Ready(unique_txs.into_iter().collect())
177+
for tx in fixed_txs {
178+
// filter unique transactions
179+
if auto_txs.iter().any(|auto_tx| auto_tx.hash() == tx.hash()) {
180+
continue;
181+
}
182+
auto_txs.push(tx);
183+
}
184+
Poll::Ready(auto_txs)
184185
}
185186
// Only auto transactions are ready, return them
186187
(Poll::Ready(auto_txs), Poll::Pending) => Poll::Ready(auto_txs),
187188
// Only fixed transactions are ready or both are pending,
188189
// return fixed transactions or pending status
189-
(_, fixed_txs) => fixed_txs,
190+
(Poll::Pending, fixed_txs) => fixed_txs,
190191
}
191192
}
192193
}

crates/anvil/src/eth/pool/transactions.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,6 @@ impl fmt::Debug for PoolTransaction {
108108
}
109109
}
110110

111-
impl PartialOrd for PoolTransaction {
112-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
113-
Some(self.cmp(other))
114-
}
115-
}
116-
117-
impl Ord for PoolTransaction {
118-
fn cmp(&self, other: &Self) -> Ordering {
119-
self.hash().cmp(&other.hash())
120-
}
121-
}
122-
123111
impl TryFrom<RpcTransaction> for PoolTransaction {
124112
type Error = eyre::Error;
125113
fn try_from(transaction: RpcTransaction) -> Result<Self, Self::Error> {

crates/anvil/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle
151151
let mode = if let Some(block_time) = block_time {
152152
if mixed_mining {
153153
let listener = pool.add_ready_listener();
154-
MiningMode::mixed(max_transactions, listener, block_time);
154+
MiningMode::mixed(max_transactions, listener, block_time)
155+
} else {
156+
MiningMode::interval(block_time)
155157
}
156-
MiningMode::interval(block_time)
157158
} else if no_mining {
158159
MiningMode::None
159160
} else {

0 commit comments

Comments
 (0)