mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
core/txpool/legacypool: improve naming
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
f2b434bbf9
commit
0d41d250ce
2 changed files with 14 additions and 14 deletions
|
|
@ -1400,11 +1400,11 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) {
|
||||||
// invalidated transactions (low nonce, low balance) are deleted.
|
// invalidated transactions (low nonce, low balance) are deleted.
|
||||||
func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.Transaction {
|
func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.Transaction {
|
||||||
gasLimit := pool.currentHead.Load().GasLimit
|
gasLimit := pool.currentHead.Load().GasLimit
|
||||||
promoteable, removeable := pool.queue.promoteExecutables(accounts, gasLimit, pool.currentState, pool.pendingNonces)
|
promotable, dropped := pool.queue.promoteExecutables(accounts, gasLimit, pool.currentState, pool.pendingNonces)
|
||||||
promoted := make([]*types.Transaction, 0, len(promoteable))
|
promoted := make([]*types.Transaction, 0, len(promotable))
|
||||||
|
|
||||||
// promote all promoteable transactions
|
// promote all promoteable transactions
|
||||||
for _, tx := range promoteable {
|
for _, tx := range promotable {
|
||||||
from, _ := pool.signer.Sender(tx)
|
from, _ := pool.signer.Sender(tx)
|
||||||
if pool.promoteTx(from, tx.Hash(), tx) {
|
if pool.promoteTx(from, tx.Hash(), tx) {
|
||||||
promoted = append(promoted, tx)
|
promoted = append(promoted, tx)
|
||||||
|
|
@ -1412,7 +1412,7 @@ func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.T
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove all removable transactions
|
// remove all removable transactions
|
||||||
for _, hash := range removeable {
|
for _, hash := range dropped {
|
||||||
pool.all.Remove(hash)
|
pool.all.Remove(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,9 +152,9 @@ func (q *queue) add(hash common.Hash, tx *types.Transaction) (*common.Hash, erro
|
||||||
// Returns two lists: all transactions that were removed from the queue and selected
|
// Returns two lists: all transactions that were removed from the queue and selected
|
||||||
// for promotion; all other transactions that were removed from the queue and dropped.
|
// for promotion; all other transactions that were removed from the queue and dropped.
|
||||||
func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, currentState *state.StateDB, nonces *noncer) ([]*types.Transaction, []common.Hash) {
|
func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, currentState *state.StateDB, nonces *noncer) ([]*types.Transaction, []common.Hash) {
|
||||||
// Track the promoteable transactions to broadcast them at once
|
// Track the promotable transactions to broadcast them at once
|
||||||
var promoteable []*types.Transaction
|
var promotable []*types.Transaction
|
||||||
var removeable []common.Hash
|
var dropped []common.Hash
|
||||||
|
|
||||||
// Iterate over all accounts and promote any executable transactions
|
// Iterate over all accounts and promote any executable transactions
|
||||||
for _, addr := range accounts {
|
for _, addr := range accounts {
|
||||||
|
|
@ -165,32 +165,32 @@ func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, c
|
||||||
// Drop all transactions that are deemed too old (low nonce)
|
// Drop all transactions that are deemed too old (low nonce)
|
||||||
forwards := list.Forward(currentState.GetNonce(addr))
|
forwards := list.Forward(currentState.GetNonce(addr))
|
||||||
for _, tx := range forwards {
|
for _, tx := range forwards {
|
||||||
removeable = append(removeable, tx.Hash())
|
dropped = append(dropped, tx.Hash())
|
||||||
}
|
}
|
||||||
log.Trace("Removing old queued transactions", "count", len(forwards))
|
log.Trace("Removing old queued transactions", "count", len(forwards))
|
||||||
// Drop all transactions that are too costly (low balance or out of gas)
|
// Drop all transactions that are too costly (low balance or out of gas)
|
||||||
drops, _ := list.Filter(currentState.GetBalance(addr), gasLimit)
|
drops, _ := list.Filter(currentState.GetBalance(addr), gasLimit)
|
||||||
for _, tx := range drops {
|
for _, tx := range drops {
|
||||||
removeable = append(removeable, tx.Hash())
|
dropped = append(dropped, tx.Hash())
|
||||||
}
|
}
|
||||||
log.Trace("Removing unpayable queued transactions", "count", len(drops))
|
log.Trace("Removing unpayable queued transactions", "count", len(drops))
|
||||||
queuedNofundsMeter.Mark(int64(len(drops)))
|
queuedNofundsMeter.Mark(int64(len(drops)))
|
||||||
|
|
||||||
// Gather all executable transactions and promote them
|
// Gather all executable transactions and promote them
|
||||||
readies := list.Ready(nonces.get(addr))
|
readies := list.Ready(nonces.get(addr))
|
||||||
promoteable = append(promoteable, readies...)
|
promotable = append(promotable, readies...)
|
||||||
log.Trace("Promoting queued transactions", "count", len(promoteable))
|
log.Trace("Promoting queued transactions", "count", len(promotable))
|
||||||
queuedGauge.Dec(int64(len(readies)))
|
queuedGauge.Dec(int64(len(readies)))
|
||||||
|
|
||||||
// Drop all transactions over the allowed limit
|
// Drop all transactions over the allowed limit
|
||||||
var caps = list.Cap(int(q.config.AccountQueue))
|
var caps = list.Cap(int(q.config.AccountQueue))
|
||||||
for _, tx := range caps {
|
for _, tx := range caps {
|
||||||
hash := tx.Hash()
|
hash := tx.Hash()
|
||||||
removeable = append(removeable, hash)
|
dropped = append(dropped, hash)
|
||||||
log.Trace("Removing cap-exceeding queued transaction", "hash", hash)
|
log.Trace("Removing cap-exceeding queued transaction", "hash", hash)
|
||||||
}
|
}
|
||||||
queuedRateLimitMeter.Mark(int64(len(caps)))
|
queuedRateLimitMeter.Mark(int64(len(caps)))
|
||||||
queuedGauge.Dec(int64(len(removeable)))
|
queuedGauge.Dec(int64(len(dropped)))
|
||||||
|
|
||||||
// Delete the entire queue entry if it became empty.
|
// Delete the entire queue entry if it became empty.
|
||||||
if list.Empty() {
|
if list.Empty() {
|
||||||
|
|
@ -198,7 +198,7 @@ func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, c
|
||||||
delete(q.beats, addr)
|
delete(q.beats, addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return promoteable, removeable
|
return promotable, dropped
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *queue) truncate() []common.Hash {
|
func (q *queue) truncate() []common.Hash {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue