mirror of https://github.com/vacp2p/nim-libp2p.git
nil check peer before disconnect
This commit is contained in:
parent
f9e0a1f069
commit
4e12d0d97a
|
@ -138,7 +138,8 @@ method publish*(f: FloodSub,
|
||||||
let (published, failed) = await f.sendHelper(f.floodsub.getOrDefault(topic), @[msg])
|
let (published, failed) = await f.sendHelper(f.floodsub.getOrDefault(topic), @[msg])
|
||||||
for p in failed:
|
for p in failed:
|
||||||
let peer = f.peers.getOrDefault(p)
|
let peer = f.peers.getOrDefault(p)
|
||||||
f.handleDisconnect(peer) # cleanup failed peers
|
if not isNil(peer):
|
||||||
|
f.handleDisconnect(peer) # cleanup failed peers
|
||||||
|
|
||||||
libp2p_pubsub_messages_published.inc(labelValues = [topic])
|
libp2p_pubsub_messages_published.inc(labelValues = [topic])
|
||||||
|
|
||||||
|
|
|
@ -450,7 +450,7 @@ method rpcHandler*(g: GossipSub,
|
||||||
let (published, failed) = await g.sendHelper(toSendPeers, m.messages)
|
let (published, failed) = await g.sendHelper(toSendPeers, m.messages)
|
||||||
for p in failed:
|
for p in failed:
|
||||||
let peer = g.peers.getOrDefault(p)
|
let peer = g.peers.getOrDefault(p)
|
||||||
if not(isNil(peer)):
|
if not isNil(peer):
|
||||||
g.handleDisconnect(peer) # cleanup failed peers
|
g.handleDisconnect(peer) # cleanup failed peers
|
||||||
|
|
||||||
trace "forwared message to peers", peers = published.len
|
trace "forwared message to peers", peers = published.len
|
||||||
|
@ -523,7 +523,8 @@ method publish*(g: GossipSub,
|
||||||
let (published, failed) = await g.sendHelper(peers, @[msg])
|
let (published, failed) = await g.sendHelper(peers, @[msg])
|
||||||
for p in failed:
|
for p in failed:
|
||||||
let peer = g.peers.getOrDefault(p)
|
let peer = g.peers.getOrDefault(p)
|
||||||
g.handleDisconnect(peer) # cleanup failed peers
|
if not isNil(peer):
|
||||||
|
g.handleDisconnect(peer) # cleanup failed peers
|
||||||
|
|
||||||
if published.len > 0:
|
if published.len > 0:
|
||||||
libp2p_pubsub_messages_published.inc(labelValues = [topic])
|
libp2p_pubsub_messages_published.inc(labelValues = [topic])
|
||||||
|
|
Loading…
Reference in New Issue