core/txpool/legacypool: count only valid as valid

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-10-09 14:30:15 +02:00
parent a9a6192e33
commit ad6b106951
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E

View file

@ -965,7 +965,6 @@ func (pool *LegacyPool) Add(txs []*types.Transaction, sync bool) []error {
pool.mu.Lock()
newErrs, dirtyAddrs := pool.addTxsLocked(news)
pool.mu.Unlock()
validTxMeter.Mark(int64(len(news)))
var nilSlot = 0
for _, err := range newErrs {
@ -985,16 +984,24 @@ func (pool *LegacyPool) Add(txs []*types.Transaction, sync bool) []error {
// addTxsLocked attempts to queue a batch of transactions if they are valid.
// The transaction pool lock must be held.
// Returns the error for each tx, and the set of accounts that might became promotable.
func (pool *LegacyPool) addTxsLocked(txs []*types.Transaction) ([]error, *accountSet) {
dirty := newAccountSet(pool.signer)
errs := make([]error, len(txs))
var (
dirty = newAccountSet(pool.signer)
errs = make([]error, len(txs))
valid int64
)
for i, tx := range txs {
replaced, err := pool.add(tx)
errs[i] = err
if err == nil && !replaced {
dirty.addTx(tx)
if err == nil {
if !replaced {
dirty.addTx(tx)
}
valid++
}
}
validTxMeter.Mark(valid)
return errs, dirty
}