mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
eth/handler: check for tx on chain as well
The fetcher should not fetch transactions that are already on chain. Until now we were only checking in the txpool, but that does not have the old transaction. Here we extend the check to the chain as well. Still WIP, as this check might be expensive, and there are other options to do the same check. Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
472e3a24ac
commit
cc11ffd463
1 changed files with 10 additions and 2 deletions
|
|
@ -179,9 +179,17 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
|||
addTxs := func(txs []*types.Transaction) []error {
|
||||
return h.txpool.Add(txs, false)
|
||||
}
|
||||
|
||||
hasTx := func(hash common.Hash) bool {
|
||||
txpoolHas := h.txpool.Has(hash)
|
||||
// check on chain as well (no need to check limbo separately, as chain checks limbo too)
|
||||
_, tx := h.chain.GetCanonicalTransaction(hash)
|
||||
if !txpoolHas && tx != nil {
|
||||
log.Trace("handler: hasTx found tx on chain", "txhash", hash)
|
||||
}
|
||||
return txpoolHas || tx != nil
|
||||
}
|
||||
validateMeta := func(tx common.Hash, kind byte) error {
|
||||
if h.txpool.Has(tx) {
|
||||
if hasTx(tx) {
|
||||
return txpool.ErrAlreadyKnown
|
||||
}
|
||||
if !h.txpool.FilterType(kind) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue