GetMetadata can return nil

This commit is contained in:
healthykim 2026-02-09 15:04:36 -05:00
parent f8763cbf49
commit 909d38901d

View file

@ -477,29 +477,30 @@ func (h *handler) BroadcastTransactions(txs []common.Hash) {
) )
for _, tx := range txs { for _, tx := range txs {
var directSet map[*ethPeer]struct{} if meta := h.txpool.GetMetadata(tx); meta != nil {
meta := h.txpool.GetMetadata(tx) var directSet map[*ethPeer]struct{}
switch { switch {
case meta.Type == types.BlobTxType: case meta.Type == types.BlobTxType:
blobTxs++ blobTxs++
case meta.Size > txMaxBroadcastSize: case meta.Size > txMaxBroadcastSize:
largeTxs++ largeTxs++
default: default:
// Get transaction sender address. Here we can ignore any error // Get transaction sender address. Here we can ignore any error
// since we're just interested in any value. // since we're just interested in any value.
directSet = choice.choosePeers(peers, meta.Sender) directSet = choice.choosePeers(peers, meta.Sender)
}
for _, peer := range peers {
if peer.KnownTransaction(tx) {
continue
} }
if _, ok := directSet[peer]; ok {
// Send direct. for _, peer := range peers {
txset[peer] = append(txset[peer], tx) if peer.KnownTransaction(tx) {
} else { continue
// Send announcement. }
annos[peer] = append(annos[peer], tx) if _, ok := directSet[peer]; ok {
// Send direct.
txset[peer] = append(txset[peer], tx)
} else {
// Send announcement.
annos[peer] = append(annos[peer], tx)
}
} }
} }
} }