fix: only block peer if we have the id, and the maps were flipped

This commit is contained in:
Derrick Hammer 2024-01-15 11:38:38 -05:00
parent fc10a265a7
commit ab53dbdf08
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 11 additions and 9 deletions

View File

@ -239,17 +239,19 @@ func (p *P2PImpl) ConnectToNode(connectionUris []*url.URL, retried bool, fromPee
p.outgoingPeerFailures.Put(idString, counter) p.outgoingPeerFailures.Put(idString, counter)
if counter >= p.maxOutgoingPeerFailures { if counter >= p.maxOutgoingPeerFailures {
if fromPeer != nil {
fromPeerId, err := fromPeer.Id().ToString() fromPeerId, err := fromPeer.Id().ToString()
if err != nil { if err != nil {
return err return err
} }
p.outgoingPeerBlocklist.Put(fromPeerId, true) p.incomingPeerBlockList.Put(fromPeerId, true)
p.incomingPeerBlockList.Put(idString, true)
err = fromPeer.End() err = fromPeer.End()
if err != nil { if err != nil {
return err return err
} }
} }
p.outgoingPeerBlocklist.Put(idString, true)
}
return nil return nil
} }