diff --git a/libp2p/daemon/daemonapi.nim b/libp2p/daemon/daemonapi.nim index 49549d6cf..5fa1c6b66 100644 --- a/libp2p/daemon/daemonapi.nim +++ b/libp2p/daemon/daemonapi.nim @@ -112,7 +112,8 @@ proc requestIdentity(): ProtoBuffer = result.finish() proc requestConnect(peerid: PeerID, - addresses: openarray[MultiAddress]): ProtoBuffer = + addresses: openarray[MultiAddress], + timeout = 0): ProtoBuffer = ## https://github.com/libp2p/go-libp2p-daemon/blob/master/conn.go ## Processing function `doConnect(req *pb.Request)`. result = initProtoBuffer({WithVarintLength}) @@ -120,6 +121,8 @@ proc requestConnect(peerid: PeerID, msg.write(initProtoField(1, peerid)) for item in addresses: msg.write(initProtoField(2, item)) + if timeout > 0: + msg.write(initProtoField(3, timeout)) result.write(initProtoField(1, cast[uint](RequestType.CONNECT))) result.write(initProtoField(2, msg)) result.finish() @@ -135,7 +138,8 @@ proc requestDisconnect(peerid: PeerID): ProtoBuffer = result.finish() proc requestStreamOpen(peerid: PeerID, - protocols: openarray[string]): ProtoBuffer = + protocols: openarray[string], + timeout = 0): ProtoBuffer = ## https://github.com/libp2p/go-libp2p-daemon/blob/master/conn.go ## Processing function `doStreamOpen(req *pb.Request)`. result = initProtoBuffer({WithVarintLength}) @@ -143,6 +147,8 @@ proc requestStreamOpen(peerid: PeerID, msg.write(initProtoField(1, peerid)) for item in protocols: msg.write(initProtoField(2, item)) + if timeout > 0: + msg.write(initProtoField(3, timeout)) result.write(initProtoField(1, cast[uint](RequestType.STREAM_OPEN))) result.write(initProtoField(3, msg)) result.finish() diff --git a/libp2p/varint.nim b/libp2p/varint.nim index e264db6a0..506412f7c 100644 --- a/libp2p/varint.nim +++ b/libp2p/varint.nim @@ -16,7 +16,7 @@ import bitops type - VarintStatus* = enum + VarintStatus* {.pure.} = enum Error, Success, Overflow,