mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-07 15:23:08 +00:00
feat: avoid repeated checksum calculations (#599)
We don't need to recalculate the checksum for each peer.
This commit is contained in:
parent
b50197ee8b
commit
f486808fbe
@ -1196,11 +1196,11 @@ func (gs *GossipSubRouter) Publish(msg *Message) {
|
|||||||
gs.lastpub[topic] = time.Now().UnixNano()
|
gs.lastpub[topic] = time.Now().UnixNano()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
csum := computeChecksum(gs.p.idGen.ID(msg))
|
||||||
for p := range gmap {
|
for p := range gmap {
|
||||||
mid := gs.p.idGen.ID(msg)
|
|
||||||
// Check if it has already received an IDONTWANT for the message.
|
// Check if it has already received an IDONTWANT for the message.
|
||||||
// If so, don't send it to the peer
|
// 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
|
continue
|
||||||
}
|
}
|
||||||
tosend[p] = struct{}{}
|
tosend[p] = struct{}{}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user