From dee46c4d37b0026a76fbb861e12d2b5f3703eaea Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 5 Sep 2019 18:16:49 -0600 Subject: [PATCH] remove unneded var --- libp2p/multistream.nim | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/libp2p/multistream.nim b/libp2p/multistream.nim index b2a40cf23..9eaab4ff6 100644 --- a/libp2p/multistream.nim +++ b/libp2p/multistream.nim @@ -9,7 +9,10 @@ import sequtils, strutils import chronos -import connection, varint, vbuffer, protocol +import connection, + varint, + vbuffer, + protocols/protocol const MsgSize* = 64*1024 const Codec* = "/multistream/1.0.0" @@ -22,9 +25,9 @@ type Matcher* = proc (proto: string): bool {.gcsafe.} HandlerHolder* = object - proto: string - protocol: LPProtocol - match: Matcher + proto*: string + protocol*: LPProtocol + match*: Matcher MultisteamSelect* = ref object of RootObj handlers*: seq[HandlerHolder] @@ -47,26 +50,25 @@ proc select*(m: MultisteamSelect, if proto.len() > 0: await conn.writeLp((proto[0] & "\n")) # select proto - var ms = cast[string](await conn.readLp()) # read ms header - ms.removeSuffix("\n") - if ms != Codec: + result = cast[string](await conn.readLp()) # read ms header + result.removeSuffix("\n") + if result != Codec: return "" if proto.len() == 0: # no protocols, must be a handshake call - return ms + return - ms = cast[string](await conn.readLp()) # read the first proto - ms.removeSuffix("\n") - if ms == proto[0]: - result = ms + result = cast[string](await conn.readLp()) # read the first proto + result.removeSuffix("\n") + if result == proto[0]: + return if not result.len > 0: for p in proto[1..