getMuxedStream to more appropriate getStream (#448)
This commit is contained in:
parent
69ae24dc8d
commit
351489bfa9
|
@ -367,7 +367,7 @@ proc storeMuxer*(c: ConnManager,
|
|||
|
||||
asyncSpawn c.peerStartup(muxer.connection)
|
||||
|
||||
proc getMuxedStream*(c: ConnManager,
|
||||
proc getStream*(c: ConnManager,
|
||||
peerId: PeerID,
|
||||
dir: Direction): Future[Connection] {.async, gcsafe.} =
|
||||
## get a muxed stream for the provided peer
|
||||
|
@ -378,7 +378,7 @@ proc getMuxedStream*(c: ConnManager,
|
|||
if not(isNil(muxer)):
|
||||
return await muxer.newStream()
|
||||
|
||||
proc getMuxedStream*(c: ConnManager,
|
||||
proc getStream*(c: ConnManager,
|
||||
peerId: PeerID): Future[Connection] {.async, gcsafe.} =
|
||||
## get a muxed stream for the passed peer from any connection
|
||||
##
|
||||
|
@ -387,7 +387,7 @@ proc getMuxedStream*(c: ConnManager,
|
|||
if not(isNil(muxer)):
|
||||
return await muxer.newStream()
|
||||
|
||||
proc getMuxedStream*(c: ConnManager,
|
||||
proc getStream*(c: ConnManager,
|
||||
conn: Connection): Future[Connection] {.async, gcsafe.} =
|
||||
## get a muxed stream for the passed connection
|
||||
##
|
||||
|
|
|
@ -352,7 +352,7 @@ proc dial*(s: Switch,
|
|||
peerId: PeerID,
|
||||
protos: seq[string]): Future[Connection] {.async.} =
|
||||
trace "Dialing (existing)", peerId, protos
|
||||
let stream = await s.connManager.getMuxedStream(peerId)
|
||||
let stream = await s.connManager.getStream(peerId)
|
||||
if stream.isNil:
|
||||
raise newException(DialFailedError, "Couldn't get muxed stream")
|
||||
|
||||
|
@ -370,7 +370,7 @@ proc dial*(s: Switch,
|
|||
trace "Dialing (new)", peerId, protos
|
||||
let conn = await s.internalConnect(peerId, addrs)
|
||||
trace "Opening stream", conn
|
||||
let stream = await s.connManager.getMuxedStream(conn)
|
||||
let stream = await s.connManager.getStream(conn)
|
||||
|
||||
proc cleanup() {.async.} =
|
||||
if not(isNil(stream)):
|
||||
|
|
|
@ -87,7 +87,7 @@ suite "Connection Manager":
|
|||
connMngr.storeMuxer(muxer)
|
||||
check muxer in connMngr
|
||||
|
||||
let stream = await connMngr.getMuxedStream(peer.peerId)
|
||||
let stream = await connMngr.getStream(peer.peerId)
|
||||
check not(isNil(stream))
|
||||
check stream.peerInfo == peer
|
||||
|
||||
|
@ -107,9 +107,9 @@ suite "Connection Manager":
|
|||
connMngr.storeMuxer(muxer)
|
||||
check muxer in connMngr
|
||||
|
||||
let stream1 = await connMngr.getMuxedStream(peer.peerId, Direction.In)
|
||||
let stream1 = await connMngr.getStream(peer.peerId, Direction.In)
|
||||
check not(isNil(stream1))
|
||||
let stream2 = await connMngr.getMuxedStream(peer.peerId, Direction.Out)
|
||||
let stream2 = await connMngr.getStream(peer.peerId, Direction.Out)
|
||||
check isNil(stream2)
|
||||
|
||||
await connMngr.close()
|
||||
|
@ -128,7 +128,7 @@ suite "Connection Manager":
|
|||
connMngr.storeMuxer(muxer)
|
||||
check muxer in connMngr
|
||||
|
||||
let stream = await connMngr.getMuxedStream(conn)
|
||||
let stream = await connMngr.getStream(conn)
|
||||
check not(isNil(stream))
|
||||
|
||||
await connMngr.close()
|
||||
|
|
Loading…
Reference in New Issue