File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
crates/anvil/src/eth/pool Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ impl Pool {
7575 /// Returns the number of tx that are ready and queued for further execution
7676 pub fn txpool_status ( & self ) -> TxpoolStatus {
7777 // Note: naming differs here compared to geth's `TxpoolStatus`
78- let pending: u64 = self . ready_transactions ( ) . count ( ) . try_into ( ) . unwrap_or ( 0 ) ;
78+ let pending: u64 = self . inner . read ( ) . ready_transactions . len ( ) . try_into ( ) . unwrap_or ( 0 ) ;
7979 let queued: u64 = self . inner . read ( ) . pending_transactions . len ( ) . try_into ( ) . unwrap_or ( 0 ) ;
8080 TxpoolStatus { pending, queued }
8181 }
Original file line number Diff line number Diff line change @@ -417,6 +417,16 @@ impl ReadyTransactions {
417417 self . ready_tx . read ( ) . contains_key ( hash)
418418 }
419419
420+ /// Returns the number of ready transactions without cloning the snapshot
421+ pub fn len ( & self ) -> usize {
422+ self . ready_tx . read ( ) . len ( )
423+ }
424+
425+ /// Returns true if there are no ready transactions
426+ pub fn is_empty ( & self ) -> bool {
427+ self . ready_tx . read ( ) . is_empty ( )
428+ }
429+
420430 /// Returns the transaction for the hash if it's in the ready pool but not yet mined
421431 pub fn get ( & self , hash : & TxHash ) -> Option < ReadyTransaction > {
422432 self . ready_tx . read ( ) . get ( hash) . cloned ( )
You can’t perform that action at this time.
0 commit comments