diff --git a/libp2p/switch.nim b/libp2p/switch.nim index 2a2f92692..6ef0db5fa 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: