mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
style: small refactor for txpool_inspect (#8348)
This commit is contained in:
@ -87,10 +87,9 @@ where
|
||||
inspect: &mut BTreeMap<Address, BTreeMap<String, TxpoolInspectSummary>>,
|
||||
) {
|
||||
let entry = inspect.entry(tx.sender()).or_default();
|
||||
let key = tx.nonce().to_string();
|
||||
let tx = tx.to_recovered_transaction();
|
||||
entry.insert(
|
||||
key,
|
||||
tx.nonce().to_string(),
|
||||
TxpoolInspectSummary {
|
||||
to: tx.to(),
|
||||
value: tx.value(),
|
||||
@ -100,17 +99,18 @@ where
|
||||
);
|
||||
}
|
||||
|
||||
let mut inspect = TxpoolInspect::default();
|
||||
let AllPoolTransactions { pending, queued } = self.pool.all_transactions();
|
||||
|
||||
for pending in pending {
|
||||
insert(&pending.transaction, &mut inspect.pending);
|
||||
}
|
||||
for queued in queued {
|
||||
insert(&queued.transaction, &mut inspect.queued);
|
||||
}
|
||||
|
||||
Ok(inspect)
|
||||
Ok(TxpoolInspect {
|
||||
pending: pending.iter().fold(Default::default(), |mut acc, tx| {
|
||||
insert(&tx.transaction, &mut acc);
|
||||
acc
|
||||
}),
|
||||
queued: queued.iter().fold(Default::default(), |mut acc, tx| {
|
||||
insert(&tx.transaction, &mut acc);
|
||||
acc
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
/// Retrieves the transactions contained within the txpool, returning pending as well as queued
|
||||
|
||||
Reference in New Issue
Block a user