aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-12-30 19:32:15 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-02-01 20:58:14 +0800
commitd3642b0715f9168ee523f2cd8414f7fc4fc4ea33 (patch)
treecf975b43e4ccb23416207f2263ca2efca2eecfb0 /core
parentf85212aa86c8feac17f582ac14f6b15260015261 (diff)
downloaddexon-d3642b0715f9168ee523f2cd8414f7fc4fc4ea33.tar
dexon-d3642b0715f9168ee523f2cd8414f7fc4fc4ea33.tar.gz
dexon-d3642b0715f9168ee523f2cd8414f7fc4fc4ea33.tar.bz2
dexon-d3642b0715f9168ee523f2cd8414f7fc4fc4ea33.tar.lz
dexon-d3642b0715f9168ee523f2cd8414f7fc4fc4ea33.tar.xz
dexon-d3642b0715f9168ee523f2cd8414f7fc4fc4ea33.tar.zst
dexon-d3642b0715f9168ee523f2cd8414f7fc4fc4ea33.zip
core, eth, rpc/api: rpc method to inspect the txpool queue
Diffstat (limited to 'core')
-rw-r--r--core/transaction_pool.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/transaction_pool.go b/core/transaction_pool.go
index 54c0ddebb..456de3cb6 100644
--- a/core/transaction_pool.go
+++ b/core/transaction_pool.go
@@ -169,6 +169,36 @@ func (pool *TxPool) Stats() (pending int, queued int) {
return
}
+// Content retrieves the data content of the transaction pool, returning all the
+// pending as well as queued transactions, grouped by account and nonce.
+func (pool *TxPool) Content() (map[common.Address]map[uint64][]*types.Transaction, map[common.Address]map[uint64][]*types.Transaction) {
+ pool.mu.RLock()
+ defer pool.mu.RUnlock()
+
+ // Retrieve all the pending transactions and sort by account and by nonce
+ pending := make(map[common.Address]map[uint64][]*types.Transaction)
+ for _, tx := range pool.pending {
+ account, _ := tx.From()
+
+ owned, ok := pending[account]
+ if !ok {
+ owned = make(map[uint64][]*types.Transaction)
+ pending[account] = owned
+ }
+ owned[tx.Nonce()] = append(owned[tx.Nonce()], tx)
+ }
+ // Retrieve all the queued transactions and sort by account and by nonce
+ queued := make(map[common.Address]map[uint64][]*types.Transaction)
+ for account, txs := range pool.queue {
+ owned := make(map[uint64][]*types.Transaction)
+ for _, tx := range txs {
+ owned[tx.Nonce()] = append(owned[tx.Nonce()], tx)
+ }
+ queued[account] = owned
+ }
+ return pending, queued
+}
+
// SetLocal marks a transaction as local, skipping gas price
// check against local miner minimum in the future
func (pool *TxPool) SetLocal(tx *types.Transaction) {