Remove unnecessary async (#836)
This commit is contained in:
parent
5e3323d43f
commit
e304ad0f7e
|
@ -416,7 +416,7 @@ proc getIncomingSlot*(c: ConnManager): Future[ConnectionSlot] {.async.} =
|
|||
await c.inSema.acquire()
|
||||
return ConnectionSlot(connManager: c, direction: In)
|
||||
|
||||
proc getOutgoingSlot*(c: ConnManager, forceDial = false): Future[ConnectionSlot] {.async.} =
|
||||
proc getOutgoingSlot*(c: ConnManager, forceDial = false): ConnectionSlot {.raises: [Defect, TooManyConnectionsError].} =
|
||||
if forceDial:
|
||||
c.outSema.forceAcquire()
|
||||
elif not c.outSema.tryAcquire():
|
||||
|
|
|
@ -177,7 +177,7 @@ proc internalConnect(
|
|||
trace "Reusing existing connection", conn, direction = $conn.dir
|
||||
return conn
|
||||
|
||||
let slot = await self.connManager.getOutgoingSlot(forceDial)
|
||||
let slot = self.connManager.getOutgoingSlot(forceDial)
|
||||
conn =
|
||||
try:
|
||||
await self.dialAndUpgrade(peerId, addrs)
|
||||
|
|
|
@ -259,11 +259,11 @@ suite "Connection Manager":
|
|||
let connMngr = ConnManager.new(maxConnections = 3)
|
||||
|
||||
for i in 0..<3:
|
||||
check await connMngr.getOutgoingSlot().withTimeout(10.millis)
|
||||
discard connMngr.getOutgoingSlot()
|
||||
|
||||
# should throw adding a connection over the limit
|
||||
expect TooManyConnectionsError:
|
||||
discard await connMngr.getOutgoingSlot()
|
||||
discard connMngr.getOutgoingSlot()
|
||||
|
||||
await connMngr.close()
|
||||
|
||||
|
@ -271,7 +271,7 @@ suite "Connection Manager":
|
|||
let connMngr = ConnManager.new(maxConnections = 3)
|
||||
|
||||
for i in 0..<3:
|
||||
check await connMngr.getOutgoingSlot().withTimeout(10.millis)
|
||||
discard connMngr.getOutgoingSlot()
|
||||
|
||||
# should timeout adding a connection over the limit
|
||||
check not(await connMngr.getIncomingSlot().withTimeout(10.millis))
|
||||
|
@ -286,7 +286,7 @@ suite "Connection Manager":
|
|||
|
||||
# should throw adding a connection over the limit
|
||||
expect TooManyConnectionsError:
|
||||
discard await connMngr.getOutgoingSlot()
|
||||
discard connMngr.getOutgoingSlot()
|
||||
|
||||
await connMngr.close()
|
||||
|
||||
|
@ -304,11 +304,11 @@ suite "Connection Manager":
|
|||
let connMngr = ConnManager.new(maxOut = 3)
|
||||
|
||||
for i in 0..<3:
|
||||
check await connMngr.getOutgoingSlot().withTimeout(10.millis)
|
||||
discard connMngr.getOutgoingSlot()
|
||||
|
||||
# should throw adding a connection over the limit
|
||||
expect TooManyConnectionsError:
|
||||
discard await connMngr.getOutgoingSlot()
|
||||
discard connMngr.getOutgoingSlot()
|
||||
|
||||
await connMngr.close()
|
||||
|
||||
|
@ -316,7 +316,7 @@ suite "Connection Manager":
|
|||
let connMngr = ConnManager.new(maxOut = 3)
|
||||
|
||||
for i in 0..<3:
|
||||
check await connMngr.getOutgoingSlot().withTimeout(10.millis)
|
||||
discard connMngr.getOutgoingSlot()
|
||||
|
||||
# should timeout adding a connection over the limit
|
||||
check not(await connMngr.getIncomingSlot().withTimeout(10.millis))
|
||||
|
@ -332,7 +332,7 @@ suite "Connection Manager":
|
|||
|
||||
# should throw adding a connection over the limit
|
||||
expect TooManyConnectionsError:
|
||||
discard await connMngr.getOutgoingSlot()
|
||||
discard connMngr.getOutgoingSlot()
|
||||
|
||||
await connMngr.close()
|
||||
|
||||
|
@ -341,11 +341,11 @@ suite "Connection Manager":
|
|||
|
||||
var conns: seq[Connection]
|
||||
for i in 0..<3:
|
||||
check await connMngr.getOutgoingSlot(true).withTimeout(10.millis)
|
||||
discard connMngr.getOutgoingSlot(true)
|
||||
|
||||
# should throw adding a connection over the limit
|
||||
expect TooManyConnectionsError:
|
||||
discard await connMngr.getOutgoingSlot(false)
|
||||
discard connMngr.getOutgoingSlot(false)
|
||||
|
||||
await connMngr.close()
|
||||
|
||||
|
@ -354,7 +354,7 @@ suite "Connection Manager":
|
|||
|
||||
var conns: seq[Connection]
|
||||
for i in 0..<3:
|
||||
let slot = await ((connMngr.getOutgoingSlot()).wait(10.millis))
|
||||
let slot = connMngr.getOutgoingSlot()
|
||||
|
||||
let conn =
|
||||
getConnection(
|
||||
|
|
Loading…
Reference in New Issue