From 351489bfa9555403d3f45a074883c8a379f7dda5 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 24 Nov 2020 00:37:45 -0600 Subject: [PATCH] getMuxedStream to more appropriate getStream (#448) --- libp2p/connmanager.nim | 6 +++--- libp2p/switch.nim | 4 ++-- tests/testconnmngr.nim | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libp2p/connmanager.nim b/libp2p/connmanager.nim index a62600201..2d90c2d9e 100644 --- a/libp2p/connmanager.nim +++ b/libp2p/connmanager.nim @@ -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 ## diff --git a/libp2p/switch.nim b/libp2p/switch.nim index 398fd7809..726a3a0e6 100644 --- a/libp2p/switch.nim +++ b/libp2p/switch.nim @@ -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)): diff --git a/tests/testconnmngr.nim b/tests/testconnmngr.nim index 8d1c3a607..8afad8a82 100644 --- a/tests/testconnmngr.nim +++ b/tests/testconnmngr.nim @@ -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()