From 19d3d57d4cf7724d270678178dad9fdf142adc8f Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni Date: Thu, 16 Jul 2020 21:59:33 +0900 Subject: [PATCH] small sugar --- libp2p/peerinfo.nim | 14 +++++++------- libp2p/protocols/pubsub/pubsubpeer.nim | 8 +++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libp2p/peerinfo.nim b/libp2p/peerinfo.nim index f3892bf05..c50010734 100644 --- a/libp2p/peerinfo.nim +++ b/libp2p/peerinfo.nim @@ -147,10 +147,10 @@ func `==`*(a, b: PeerInfo): bool = bptr = cast[pointer](b) if isNil(aptr) and isNil(bptr): - return true - - if isNil(aptr) or isNil(bptr): - return false - - if aptr == bptr and a.peerId == b.peerId: - return true + true + elif isNil(aptr) or isNil(bptr): + false + elif aptr == bptr and a.peerId == b.peerId: + true + else: + false diff --git a/libp2p/protocols/pubsub/pubsubpeer.nim b/libp2p/protocols/pubsub/pubsubpeer.nim index 24287284d..07a75dcef 100644 --- a/libp2p/protocols/pubsub/pubsubpeer.nim +++ b/libp2p/protocols/pubsub/pubsubpeer.nim @@ -65,7 +65,13 @@ func `==`*(a, b: PubSubPeer): bool = bptr = cast[pointer](b) if isNil(aptr) and isNil(bptr): - return true + true + elif isNil(aptr) or isNil(bptr): + false + elif aptr == bptr and a.peerInfo == b.peerInfo: + true + else: + false proc id*(p: PubSubPeer): string = p.peerInfo.id