Skip to content

Commit 11218e8

Browse files
authored
txpool: Move Ingress Filter Checks to addTxsLocked (#642)
1 parent 3c0b5b3 commit 11218e8

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

core/txpool/legacypool/legacypool.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,20 +1041,6 @@ func (pool *LegacyPool) Add(txs []*types.Transaction, sync bool) []error {
10411041
invalidTxMeter.Mark(1)
10421042
continue
10431043
}
1044-
// Exclude transactions which fail the ingress filters
1045-
filtered := false
1046-
for _, filter := range pool.ingressFilters {
1047-
if !filter.FilterTx(pool.filterCtx, tx) {
1048-
errs[i] = core.ErrTxFilteredOut
1049-
log.Trace("Discarding filtered transaction", "hash", tx.Hash())
1050-
invalidTxMeter.Mark(1)
1051-
filtered = true
1052-
break
1053-
}
1054-
}
1055-
if filtered {
1056-
continue
1057-
}
10581044
// Accumulate all unknown transactions for deeper processing
10591045
news = append(news, tx)
10601046
}
@@ -1089,6 +1075,20 @@ func (pool *LegacyPool) addTxsLocked(txs []*types.Transaction) ([]error, *accoun
10891075
dirty := newAccountSet(pool.signer)
10901076
errs := make([]error, len(txs))
10911077
for i, tx := range txs {
1078+
// Exclude transactions which fail the ingress filters
1079+
filtered := false
1080+
for _, filter := range pool.ingressFilters {
1081+
if !filter.FilterTx(pool.filterCtx, tx) {
1082+
errs[i] = core.ErrTxFilteredOut
1083+
log.Trace("Discarding filtered transaction", "hash", tx.Hash())
1084+
invalidTxMeter.Mark(1)
1085+
filtered = true
1086+
break
1087+
}
1088+
}
1089+
if filtered {
1090+
continue
1091+
}
10921092
replaced, err := pool.add(tx)
10931093
errs[i] = err
10941094
if err == nil && !replaced {

0 commit comments

Comments
 (0)