eth/protocols/eth: fix track-before-send (#35056)

Track the transaction only after it was sent out
This commit is contained in:
cui 2026-05-28 16:05:40 +08:00 committed by GitHub
parent b0df33967c
commit 10a1982203
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -159,11 +159,13 @@ func (p *Peer) MarkTransaction(hash common.Hash) {
// The reasons this is public is to allow packages using this protocol to write // The reasons this is public is to allow packages using this protocol to write
// tests that directly send messages without having to do the async queueing. // tests that directly send messages without having to do the async queueing.
func (p *Peer) SendTransactions(txs types.Transactions) error { func (p *Peer) SendTransactions(txs types.Transactions) error {
// Mark all the transactions as known, but ensure we don't overflow our limits if err := p2p.Send(p.rw, TransactionsMsg, txs); err != nil {
return err
}
for _, tx := range txs { for _, tx := range txs {
p.knownTxs.Add(tx.Hash()) p.knownTxs.Add(tx.Hash())
} }
return p2p.Send(p.rw, TransactionsMsg, txs) return nil
} }
// AsyncSendTransactions queues a list of transactions (by hash) to eventually // AsyncSendTransactions queues a list of transactions (by hash) to eventually