From e5be1fcaee599651bce13d789766141f8bd1dfe1 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 29 Aug 2019 23:17:07 -0600 Subject: [PATCH] wip: switch --- libp2p/switch.nim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libp2p/switch.nim b/libp2p/switch.nim index 2a2f926..6ef0db5 100644 --- a/libp2p/switch.nim +++ b/libp2p/switch.nim @@ -10,33 +10,33 @@ import tables import chronos import connection, transport, stream, - peerinfo, multiaddress, multistreamselect, - protocol + multistreamselect, protocol, + peerinfo, multiaddress type Switch* = ref object of RootObj - peerInfo*: PeerInfo - connections*: TableRef[string, Connection] - transports*: seq[Transport] - protocols*: seq[Protocol] - ms*: MultisteamSelect + peerInfo*: PeerInfo + connections*: TableRef[string, Connection] + transports*: seq[Transport] + protocols*: seq[LPProtocol] + ms*: MultisteamSelect proc newSwitch*(peerInfo: PeerInfo, transports: seq[Transport]): Switch = new result result.peerInfo = peerInfo result.ms = newMultistream() result.transports = transports - result.protocols = newSeq[switchtypes.Protocol]() + result.protocols = newSeq[LPProtocol]() result.connections = newTable[string, Connection]() proc dial*(s: Switch, peer: PeerInfo, proto: string = ""): Future[Connection] {.async.} = discard -proc mount*(s: Switch, protocol: protocol.Protocol) = discard +proc mount*(s: Switch, protocol: LPProtocol) = discard proc start*(s: Switch) {.async.} = # TODO: how bad is it that this is a closure? proc handle(conn: Connection): Future[void] {.closure, gcsafe.} = - discard + s.ms.handle(conn) for t in s.transports: # for each transport for a in s.peerInfo.addrs: