From 054bd365af05d8026fc4d5dd8a98271f703be104 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 29 Aug 2019 14:55:30 -0600 Subject: [PATCH] protocol handler method should receive context --- libp2p/protocol.nim | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libp2p/protocol.nim b/libp2p/protocol.nim index 896d524..eb64244 100644 --- a/libp2p/protocol.nim +++ b/libp2p/protocol.nim @@ -9,21 +9,22 @@ import chronos import connection, transport, stream, - peerinfo, multiaddress, multistreamselect + peerinfo, multiaddress type - ProtoHandler* = proc (conn: Connection, proto: string): Future[void] {.gcsafe.} - Protocol* = ref object of RootObj + LPProtoHandler* = proc (protocol: LPProtocol, + conn: Connection, + proto: string): Future[void] {.gcsafe.} + LPProtocol* = ref object of RootObj peerInfo*: PeerInfo codec*: string -proc newProtocol*(p: typedesc[Protocol], +proc newProtocol*(p: typedesc[LPProtocol], peerInfo: PeerInfo): p = new result result.peerInfo = peerInfo result.init() -method init*(p: Protocol) {.base.} = discard - -method handle*(p: Protocol, peerInfo: PeerInfo, handler: ProtoHandler) - {.base, async, error: "not implemented!".} = discard +method init*(p: LPProtocol) {.base.} = discard +method handle*(protocol: LPProtocol, conn: Connection, proto: string): Future[void] + {.base, async.} = discard