eth/handler: simplify code

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-12-18 09:57:15 +01:00
parent d220e4c844
commit 1559979671
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E

View file

@ -179,18 +179,12 @@ func newHandler(config *handlerConfig) (*handler, error) {
addTxs := func(txs []*types.Transaction) []error {
return h.txpool.Add(txs, false)
}
hasTx := func(hash common.Hash) bool {
return h.txpool.Has(hash)
}
chainTx := func(hash common.Hash) bool {
// check on chain (no need to check limbo separately, as chain checks limbo too)
return h.chain.HasCanonicalTransaction(hash, true)
}
validateMeta := func(tx common.Hash, kind byte) error {
if hasTx(tx) {
validateMeta := func(hash common.Hash, kind byte) error {
if h.txpool.Has(hash) {
return txpool.ErrAlreadyKnown
}
if chainTx(tx) {
// check on chain as well (no need to check limbo separately, as chain checks limbo too)
if h.chain.HasCanonicalTransaction(hash, true) {
return txpool.ErrAlreadyKnown
}
if !h.txpool.FilterType(kind) {