Removes inflight semaphore
This commit is contained in:
parent
d1152117ca
commit
26ec15c6f7
|
@ -75,7 +75,6 @@ type
|
||||||
handlers*: BlockExcHandlers
|
handlers*: BlockExcHandlers
|
||||||
request*: BlockExcRequest
|
request*: BlockExcRequest
|
||||||
getConn: ConnProvider
|
getConn: ConnProvider
|
||||||
inflightSema: AsyncSemaphore
|
|
||||||
|
|
||||||
proc peerId*(b: BlockExcNetwork): PeerId =
|
proc peerId*(b: BlockExcNetwork): PeerId =
|
||||||
## Return peer id
|
## Return peer id
|
||||||
|
@ -99,14 +98,11 @@ proc send*(b: BlockExcNetwork, id: PeerId, msg: pb.Message) {.async.} =
|
||||||
|
|
||||||
let peer = b.peers[id]
|
let peer = b.peers[id]
|
||||||
try:
|
try:
|
||||||
await b.inflightSema.acquire()
|
|
||||||
await peer.send(msg)
|
await peer.send(msg)
|
||||||
except CancelledError as error:
|
except CancelledError as error:
|
||||||
raise error
|
raise error
|
||||||
except CatchableError as err:
|
except CatchableError as err:
|
||||||
error "Error sending message", peer = id, msg = err.msg
|
error "Error sending message", peer = id, msg = err.msg
|
||||||
finally:
|
|
||||||
b.inflightSema.release()
|
|
||||||
|
|
||||||
proc handleWantList(
|
proc handleWantList(
|
||||||
b: BlockExcNetwork,
|
b: BlockExcNetwork,
|
||||||
|
@ -332,8 +328,7 @@ proc new*(
|
||||||
let
|
let
|
||||||
self = BlockExcNetwork(
|
self = BlockExcNetwork(
|
||||||
switch: switch,
|
switch: switch,
|
||||||
getConn: connProvider,
|
getConn: connProvider)
|
||||||
inflightSema: newAsyncSemaphore(maxInflight))
|
|
||||||
|
|
||||||
proc sendWantList(
|
proc sendWantList(
|
||||||
id: PeerId,
|
id: PeerId,
|
||||||
|
|
Loading…
Reference in New Issue