Skip to content

Commit 4d6d5a3

Browse files
authored
core/txpool/legacypool: fix validTxMeter to count transactions (#32845)
invalidTxMeter was counting txs, while validTxMeter was counting accounts. Better make the two comparable. --------- Signed-off-by: Csaba Kiraly <[email protected]>
1 parent 1120855 commit 4d6d5a3

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

core/txpool/legacypool/legacypool.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -984,17 +984,24 @@ func (pool *LegacyPool) Add(txs []*types.Transaction, sync bool) []error {
984984

985985
// addTxsLocked attempts to queue a batch of transactions if they are valid.
986986
// The transaction pool lock must be held.
987+
// Returns the error for each tx, and the set of accounts that might became promotable.
987988
func (pool *LegacyPool) addTxsLocked(txs []*types.Transaction) ([]error, *accountSet) {
988-
dirty := newAccountSet(pool.signer)
989-
errs := make([]error, len(txs))
989+
var (
990+
dirty = newAccountSet(pool.signer)
991+
errs = make([]error, len(txs))
992+
valid int64
993+
)
990994
for i, tx := range txs {
991995
replaced, err := pool.add(tx)
992996
errs[i] = err
993-
if err == nil && !replaced {
994-
dirty.addTx(tx)
997+
if err == nil {
998+
if !replaced {
999+
dirty.addTx(tx)
1000+
}
1001+
valid++
9951002
}
9961003
}
997-
validTxMeter.Mark(int64(len(dirty.accounts)))
1004+
validTxMeter.Mark(valid)
9981005
return errs, dirty
9991006
}
10001007

0 commit comments

Comments
 (0)