feat: avoid repeated checksum calculations (#599)

We don't need to recalculate the checksum for each peer.
This commit is contained in:
Aayush Rajasekaran 2025-02-23 17:39:38 -05:00 committed by GitHub
parent b50197ee8b
commit f486808fbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1196,11 +1196,11 @@ func (gs *GossipSubRouter) Publish(msg *Message) {
gs.lastpub[topic] = time.Now().UnixNano()
}
csum := computeChecksum(gs.p.idGen.ID(msg))
for p := range gmap {
mid := gs.p.idGen.ID(msg)
// Check if it has already received an IDONTWANT for the message.
// If so, don't send it to the peer
if _, ok := gs.unwanted[p][computeChecksum(mid)]; ok {
if _, ok := gs.unwanted[p][csum]; ok {
continue
}
tosend[p] = struct{}{}