From ab53dbdf08ca050cb212eaa3915d96dbce20a980 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 15 Jan 2024 11:38:38 -0500 Subject: [PATCH] fix: only block peer if we have the id, and the maps were flipped --- service/p2p.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/service/p2p.go b/service/p2p.go index 1c3d61c..087d1e1 100644 --- a/service/p2p.go +++ b/service/p2p.go @@ -239,16 +239,18 @@ func (p *P2PImpl) ConnectToNode(connectionUris []*url.URL, retried bool, fromPee p.outgoingPeerFailures.Put(idString, counter) if counter >= p.maxOutgoingPeerFailures { - fromPeerId, err := fromPeer.Id().ToString() - if err != nil { - return err - } - p.outgoingPeerBlocklist.Put(fromPeerId, true) - p.incomingPeerBlockList.Put(idString, true) - err = fromPeer.End() - if err != nil { - return err + if fromPeer != nil { + fromPeerId, err := fromPeer.Id().ToString() + if err != nil { + return err + } + p.incomingPeerBlockList.Put(fromPeerId, true) + err = fromPeer.End() + if err != nil { + return err + } } + p.outgoingPeerBlocklist.Put(idString, true) } return nil