Fixes nullref in networkPeer
This commit is contained in:
parent
b491906005
commit
67e5a3fc2e
|
@ -93,18 +93,20 @@ proc send*(b: BlockExcNetwork, id: PeerId, msg: pb.Message) {.async.} =
|
||||||
## Send message to peer
|
## Send message to peer
|
||||||
##
|
##
|
||||||
|
|
||||||
b.peers.withValue(id, peer):
|
if not (id in b.peers):
|
||||||
try:
|
|
||||||
await b.inflightSema.acquire()
|
|
||||||
await peer[].send(msg)
|
|
||||||
except CancelledError as error:
|
|
||||||
raise error
|
|
||||||
except CatchableError as err:
|
|
||||||
error "Error sending message", peer = id, msg = err.msg
|
|
||||||
finally:
|
|
||||||
b.inflightSema.release()
|
|
||||||
do:
|
|
||||||
trace "Unable to send, peer not found", peerId = id
|
trace "Unable to send, peer not found", peerId = id
|
||||||
|
return
|
||||||
|
|
||||||
|
let peer = b.peers[id]
|
||||||
|
try:
|
||||||
|
await b.inflightSema.acquire()
|
||||||
|
await peer.send(msg)
|
||||||
|
except CancelledError as error:
|
||||||
|
raise error
|
||||||
|
except CatchableError as err:
|
||||||
|
error "Error sending message", peer = id, msg = err.msg
|
||||||
|
finally:
|
||||||
|
b.inflightSema.release()
|
||||||
|
|
||||||
proc handleWantList(
|
proc handleWantList(
|
||||||
b: BlockExcNetwork,
|
b: BlockExcNetwork,
|
||||||
|
|
Loading…
Reference in New Issue