From fae38e01466041d51d650a58dd78c3dfbcfead22 Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Date: Fri, 26 Feb 2021 19:19:15 +0900 Subject: [PATCH] fix PubSubPeer hashing issues --- libp2p/protocols/pubsub/pubsubpeer.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libp2p/protocols/pubsub/pubsubpeer.nim b/libp2p/protocols/pubsub/pubsubpeer.nim index 5c816a373..1c8afed1c 100644 --- a/libp2p/protocols/pubsub/pubsubpeer.nim +++ b/libp2p/protocols/pubsub/pubsubpeer.nim @@ -64,8 +64,10 @@ type RPCHandler* = proc(peer: PubSubPeer, msg: RPCMsg): Future[void] {.gcsafe.} func hash*(p: PubSubPeer): Hash = - # int is either 32/64, so intptr basically, pubsubpeer is a ref - cast[pointer](p).hash + p.peerId.hash + +func `==`*(a, b: PubSubPeer): bool = + a.peerId == b.peerId func shortLog*(p: PubSubPeer): string = if p.isNil: "PubSubPeer(nil)"