core/txpool/legacypool: address comments from marius

This commit is contained in:
Gary Rong 2025-03-20 13:14:46 +08:00
parent bdc3e5d72f
commit 1b7228f63e

View file

@ -609,9 +609,9 @@ func (pool *LegacyPool) validateTx(tx *types.Transaction) error {
return pool.validateAuth(tx)
}
// limitTxFromDelegated ensures the account with either delegation or pending
// ensureDelegationLimit ensures the account with either delegation or pending
// delegation can at most send one inflight **executable** transaction.
func (pool *LegacyPool) limitTxFromDelegated(tx *types.Transaction) error {
func (pool *LegacyPool) ensureDelegationLimit(tx *types.Transaction) error {
from, _ := types.Sender(pool.signer, tx) // validated
// Short circuit if the sender has neither delegation nor pending delegation.
@ -630,10 +630,7 @@ func (pool *LegacyPool) limitTxFromDelegated(tx *types.Transaction) error {
if pending.Contains(tx.Nonce()) {
return nil
}
if pending.Len() >= 1 {
return ErrInflightTxLimitReached
}
return nil
}
// validateAuth verifies that the transaction complies with code authorization
@ -641,7 +638,7 @@ func (pool *LegacyPool) limitTxFromDelegated(tx *types.Transaction) error {
func (pool *LegacyPool) validateAuth(tx *types.Transaction) error {
// Allow at most one in-flight tx for delegated accounts or those with a
// pending authorization.
if err := pool.limitTxFromDelegated(tx); err != nil {
if err := pool.ensureDelegationLimit(tx); err != nil {
return err
}
// Authorities cannot conflict with any pending or queued transactions.