Skip to content

Commit f486808

Browse files
authored
feat: avoid repeated checksum calculations (#599)
We don't need to recalculate the checksum for each peer.
1 parent b50197e commit f486808

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gossipsub.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,11 +1196,11 @@ func (gs *GossipSubRouter) Publish(msg *Message) {
11961196
gs.lastpub[topic] = time.Now().UnixNano()
11971197
}
11981198

1199+
csum := computeChecksum(gs.p.idGen.ID(msg))
11991200
for p := range gmap {
1200-
mid := gs.p.idGen.ID(msg)
12011201
// Check if it has already received an IDONTWANT for the message.
12021202
// If so, don't send it to the peer
1203-
if _, ok := gs.unwanted[p][computeChecksum(mid)]; ok {
1203+
if _, ok := gs.unwanted[p][csum]; ok {
12041204
continue
12051205
}
12061206
tosend[p] = struct{}{}

0 commit comments

Comments
 (0)