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:
@ -175,6 +175,29 @@ func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string]*RPCTransac
|
||||
return content
|
||||
}
|
||||
|
||||
// ContentFrom returns the transactions contained within the transaction pool.
|
||||
func (s *PublicTxPoolAPI) ContentFrom(addr common.Address) map[string]map[string]*RPCTransaction {
|
||||
content := make(map[string]map[string]*RPCTransaction, 2)
|
||||
pending, queue := s.b.TxPoolContentFrom(addr)
|
||||
curHeader := s.b.CurrentHeader()
|
||||
|
||||
// Build the pending transactions
|
||||
dump := make(map[string]*RPCTransaction, len(pending))
|
||||
for _, tx := range pending {
|
||||
dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())
|
||||
}
|
||||
content["pending"] = dump
|
||||
|
||||
// Build the queued transactions
|
||||
dump = make(map[string]*RPCTransaction, len(queue))
|
||||
for _, tx := range queue {
|
||||
dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())
|
||||
}
|
||||
content["queued"] = dump
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
// Status returns the number of pending and queued transaction in the pool.
|
||||
func (s *PublicTxPoolAPI) Status() map[string]hexutil.Uint {
|
||||
pending, queue := s.b.Stats()
|
||||
|
Reference in New Issue
Block a user