mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
parent
e764d842da
commit
80db09613e
1 changed files with 13 additions and 20 deletions
|
|
@ -179,6 +179,15 @@ func NewTxPoolAPI(b Backend) *TxPoolAPI {
|
||||||
return &TxPoolAPI{b}
|
return &TxPoolAPI{b}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// flattenTxs builds the RPC transaction map keyed by nonce for a set of pool txs.
|
||||||
|
func flattenTxs(txs types.Transactions, header *types.Header, cfg *params.ChainConfig) map[string]*RPCTransaction {
|
||||||
|
dump := make(map[string]*RPCTransaction, len(txs))
|
||||||
|
for _, tx := range txs {
|
||||||
|
dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx, header, cfg)
|
||||||
|
}
|
||||||
|
return dump
|
||||||
|
}
|
||||||
|
|
||||||
// Content returns the transactions contained within the transaction pool.
|
// Content returns the transactions contained within the transaction pool.
|
||||||
func (s *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction {
|
func (s *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction {
|
||||||
pending, queue := s.b.TxPoolContent()
|
pending, queue := s.b.TxPoolContent()
|
||||||
|
|
@ -189,19 +198,11 @@ func (s *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction {
|
||||||
curHeader := s.b.CurrentHeader()
|
curHeader := s.b.CurrentHeader()
|
||||||
// Flatten the pending transactions
|
// Flatten the pending transactions
|
||||||
for account, txs := range pending {
|
for account, txs := range pending {
|
||||||
dump := make(map[string]*RPCTransaction, len(txs))
|
content["pending"][account.Hex()] = flattenTxs(txs, curHeader, s.b.ChainConfig())
|
||||||
for _, tx := range txs {
|
|
||||||
dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())
|
|
||||||
}
|
|
||||||
content["pending"][account.Hex()] = dump
|
|
||||||
}
|
}
|
||||||
// Flatten the queued transactions
|
// Flatten the queued transactions
|
||||||
for account, txs := range queue {
|
for account, txs := range queue {
|
||||||
dump := make(map[string]*RPCTransaction, len(txs))
|
content["queued"][account.Hex()] = flattenTxs(txs, curHeader, s.b.ChainConfig())
|
||||||
for _, tx := range txs {
|
|
||||||
dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())
|
|
||||||
}
|
|
||||||
content["queued"][account.Hex()] = dump
|
|
||||||
}
|
}
|
||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
@ -213,18 +214,10 @@ func (s *TxPoolAPI) ContentFrom(addr common.Address) map[string]map[string]*RPCT
|
||||||
curHeader := s.b.CurrentHeader()
|
curHeader := s.b.CurrentHeader()
|
||||||
|
|
||||||
// Build the pending transactions
|
// Build the pending transactions
|
||||||
dump := make(map[string]*RPCTransaction, len(pending))
|
content["pending"] = flattenTxs(pending, curHeader, s.b.ChainConfig())
|
||||||
for _, tx := range pending {
|
|
||||||
dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())
|
|
||||||
}
|
|
||||||
content["pending"] = dump
|
|
||||||
|
|
||||||
// Build the queued transactions
|
// Build the queued transactions
|
||||||
dump = make(map[string]*RPCTransaction, len(queue))
|
content["queued"] = flattenTxs(queue, curHeader, s.b.ChainConfig())
|
||||||
for _, tx := range queue {
|
|
||||||
dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())
|
|
||||||
}
|
|
||||||
content["queued"] = dump
|
|
||||||
|
|
||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue