eth/protocols/eth: only track after send is okay (#35086)

This commit is contained in:
cui 2026-06-01 10:56:23 +08:00 committed by GitHub
parent ff45d1dd7b
commit 5016e54406
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -209,14 +209,15 @@ func (p *Peer) AsyncSendPooledTransactionHashes(hashes []common.Hash) {
// ReplyPooledTransactionsRLP is the response to RequestTxs. // ReplyPooledTransactionsRLP is the response to RequestTxs.
func (p *Peer) ReplyPooledTransactionsRLP(id uint64, hashes []common.Hash, txs []rlp.RawValue) error { func (p *Peer) ReplyPooledTransactionsRLP(id uint64, hashes []common.Hash, txs []rlp.RawValue) error {
// Mark all the transactions as known, but ensure we don't overflow our limits
p.knownTxs.Add(hashes...)
// Not packed into PooledTransactionsResponse to avoid RLP decoding // Not packed into PooledTransactionsResponse to avoid RLP decoding
return p2p.Send(p.rw, PooledTransactionsMsg, &PooledTransactionsRLPPacket{ if err := p2p.Send(p.rw, PooledTransactionsMsg, &PooledTransactionsRLPPacket{
RequestId: id, RequestId: id,
PooledTransactionsRLPResponse: txs, PooledTransactionsRLPResponse: txs,
}) }); err != nil {
return err
}
p.knownTxs.Add(hashes...)
return nil
} }
// ReplyBlockHeadersRLP is the response to GetBlockHeaders. // ReplyBlockHeadersRLP is the response to GetBlockHeaders.