diff --git a/libp2p/multistreamselect.nim b/libp2p/multistreamselect.nim index a7644a1..ac59e3d 100644 --- a/libp2p/multistreamselect.nim +++ b/libp2p/multistreamselect.nim @@ -20,7 +20,7 @@ const Ls = "\x03ls\n" type MultisteamSelectException = object of CatchableError - Handler* = proc (conn: Connection, proto: string): Future[void] + Handler* = proc (conn: Connection, proto: string): Future[void] {.gcsafe.} Matcher* = proc (proto: string): bool HandlerHolder* = object diff --git a/libp2p/protocol.nim b/libp2p/protocol.nim index b4f96cc..e0bd95b 100644 --- a/libp2p/protocol.nim +++ b/libp2p/protocol.nim @@ -12,7 +12,7 @@ import connection, transport, stream, peerinfo, multiaddress, multistreamselect, switchtypes -proc newProtocol*(p: typedesc[Protocol], +proc newProtocol*(p: typedesc[switchtypes.Protocol], peerInfo: PeerInfo, switch: Switch): p = new result @@ -20,10 +20,7 @@ proc newProtocol*(p: typedesc[Protocol], result.switch = switch result.init() -method init*(p: Protocol) {.base.} = discard +method init*(p: switchtypes.Protocol) {.base.} = discard -method dial*(p: Protocol, peerInfo: PeerInfo): Future[Connection] - {.base, async, error: "not implemented!".} = discard - -method handle*(p: Protocol, peerInfo: PeerInfo, handler: ProtoHandler) +method handle*(p: switchtypes.Protocol, peerInfo: PeerInfo, handler: ProtoHandler) {.base, async, error: "not implemented!".} = discard diff --git a/libp2p/tcptransport.nim b/libp2p/tcptransport.nim index 7da7146..46a6c04 100644 --- a/libp2p/tcptransport.nim +++ b/libp2p/tcptransport.nim @@ -9,16 +9,16 @@ import chronos import transport, wire, connection, - multiaddress, connection, - multicodec, chronosstream + multiaddress, connection, + multicodec, chronosstream type TcpTransport* = ref object of Transport server*: StreamServer -method connHandler*(t: Transport, - server: StreamServer, - client: StreamTransport): Future[Connection] - {.base, gcsafe, async.} = +proc connHandler*(t: Transport, + server: StreamServer, + client: StreamTransport): Future[Connection] + {.gcsafe, async.} = let conn: Connection = newConnection(newChronosStream(server, client)) let handlerFut = if t.handler == nil: nil else: t.handler(conn) let connHolder: ConnHolder = ConnHolder(connection: conn,