Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/txpool/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func (q *queue) add(tx *types.Transaction) (*common.Hash, error) {
from, _ := types.Sender(q.signer, tx) // already validated
if q.queued[from] == nil {
q.queued[from] = newList(false)
queuedAddrsGauge.Inc(1)
}
inserted, old := q.queued[from].Add(tx, q.config.PriceBump)
if !inserted {
Expand Down Expand Up @@ -196,6 +197,7 @@ func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, c
if list.Empty() {
delete(q.queued, addr)
delete(q.beats, addr)
queuedAddrsGauge.Dec(1)
removedAddresses = append(removedAddresses, addr)
}
}
Expand Down
9 changes: 9 additions & 0 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ var (

slotsGauge = metrics.NewRegisteredGauge("txpool/slots", nil)

pendingAddrsGauge = metrics.NewRegisteredGauge("txpool/pending/accounts", nil)
queuedAddrsGauge = metrics.NewRegisteredGauge("txpool/queued/accounts", nil)

reheapTimer = metrics.NewRegisteredTimer("txpool/reheap", nil)
)

Expand Down Expand Up @@ -863,6 +866,7 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
// Try to insert the transaction into the pending queue
if pool.pending[addr] == nil {
pool.pending[addr] = newList(true)
pendingAddrsGauge.Inc(1)
}
list := pool.pending[addr]

Expand Down Expand Up @@ -1073,6 +1077,7 @@ func (pool *TxPool) removeTx(hash common.Hash, outofbound bool, unreserve bool)
// If no more pending transactions are left, remove the list
if pending.Empty() {
delete(pool.pending, addr)
pendingAddrsGauge.Dec(1)
}
// Postpone any invalidated transactions
for _, tx := range invalids {
Expand Down Expand Up @@ -1365,6 +1370,9 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
pool.currentState = statedb
pool.pendingNonces = newNoncer(statedb)

pendingAddrsGauge.Update(0)
queuedAddrsGauge.Update(0)

// Inject any transactions discarded due to reorgs
log.Debug("Reinjecting stale transactions", "count", len(reinject))
core.SenderCacher.Recover(pool.signer, reinject)
Expand Down Expand Up @@ -1568,6 +1576,7 @@ func (pool *TxPool) demoteUnexecutables() {
// Delete the entire pending entry if it became empty.
if list.Empty() {
delete(pool.pending, addr)
pendingAddrsGauge.Dec(1)
if _, ok := pool.queue.get(addr); !ok {
pool.reserver.Release(addr)
}
Expand Down
Loading