internal: get pending and queued transaction by address (#22992)
* core, eth, internal, les, light: get pending and queued transaction by address * core: tiny nitpick fixes * light: tiny nitpick Co-authored-by: mark <mark@amis.com> Co-authored-by: Péter Szilágyi <peterke@gmail.com>
This commit is contained in:
@ -505,6 +505,25 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common
|
||||
return pending, queued
|
||||
}
|
||||
|
||||
// ContentFrom retrieves the data content of the transaction pool, returning the
|
||||
// pending as well as queued transactions of this address, grouped by nonce.
|
||||
func (pool *TxPool) ContentFrom(addr common.Address) (types.Transactions, types.Transactions) {
|
||||
pool.mu.RLock()
|
||||
defer pool.mu.RUnlock()
|
||||
|
||||
// Retrieve the pending transactions and sort by nonce
|
||||
var pending types.Transactions
|
||||
for _, tx := range pool.pending {
|
||||
account, _ := types.Sender(pool.signer, tx)
|
||||
if account != addr {
|
||||
continue
|
||||
}
|
||||
pending = append(pending, tx)
|
||||
}
|
||||
// There are no queued transactions in a light pool, just return an empty map
|
||||
return pending, types.Transactions{}
|
||||
}
|
||||
|
||||
// RemoveTransactions removes all given transactions from the pool.
|
||||
func (pool *TxPool) RemoveTransactions(txs types.Transactions) {
|
||||
pool.mu.Lock()
|
||||
|
Reference in New Issue
Block a user