remove unneded var
This commit is contained in:
parent
14d9150bbb
commit
dee46c4d37
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
import sequtils, strutils
|
import sequtils, strutils
|
||||||
import chronos
|
import chronos
|
||||||
import connection, varint, vbuffer, protocol
|
import connection,
|
||||||
|
varint,
|
||||||
|
vbuffer,
|
||||||
|
protocols/protocol
|
||||||
|
|
||||||
const MsgSize* = 64*1024
|
const MsgSize* = 64*1024
|
||||||
const Codec* = "/multistream/1.0.0"
|
const Codec* = "/multistream/1.0.0"
|
||||||
|
@ -22,9 +25,9 @@ type
|
||||||
Matcher* = proc (proto: string): bool {.gcsafe.}
|
Matcher* = proc (proto: string): bool {.gcsafe.}
|
||||||
|
|
||||||
HandlerHolder* = object
|
HandlerHolder* = object
|
||||||
proto: string
|
proto*: string
|
||||||
protocol: LPProtocol
|
protocol*: LPProtocol
|
||||||
match: Matcher
|
match*: Matcher
|
||||||
|
|
||||||
MultisteamSelect* = ref object of RootObj
|
MultisteamSelect* = ref object of RootObj
|
||||||
handlers*: seq[HandlerHolder]
|
handlers*: seq[HandlerHolder]
|
||||||
|
@ -47,26 +50,25 @@ proc select*(m: MultisteamSelect,
|
||||||
if proto.len() > 0:
|
if proto.len() > 0:
|
||||||
await conn.writeLp((proto[0] & "\n")) # select proto
|
await conn.writeLp((proto[0] & "\n")) # select proto
|
||||||
|
|
||||||
var ms = cast[string](await conn.readLp()) # read ms header
|
result = cast[string](await conn.readLp()) # read ms header
|
||||||
ms.removeSuffix("\n")
|
result.removeSuffix("\n")
|
||||||
if ms != Codec:
|
if result != Codec:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
if proto.len() == 0: # no protocols, must be a handshake call
|
if proto.len() == 0: # no protocols, must be a handshake call
|
||||||
return ms
|
return
|
||||||
|
|
||||||
ms = cast[string](await conn.readLp()) # read the first proto
|
result = cast[string](await conn.readLp()) # read the first proto
|
||||||
ms.removeSuffix("\n")
|
result.removeSuffix("\n")
|
||||||
if ms == proto[0]:
|
if result == proto[0]:
|
||||||
result = ms
|
return
|
||||||
|
|
||||||
if not result.len > 0:
|
if not result.len > 0:
|
||||||
for p in proto[1..<proto.len()]:
|
for p in proto[1..<proto.len()]:
|
||||||
await conn.writeLp((p & "\n")) # select proto
|
await conn.writeLp((p & "\n")) # select proto
|
||||||
ms = cast[string](await conn.readLp()) # read the first proto
|
result = cast[string](await conn.readLp()) # read the first proto
|
||||||
ms.removeSuffix("\n")
|
result.removeSuffix("\n")
|
||||||
if ms == p:
|
if result == p:
|
||||||
result = p
|
|
||||||
break
|
break
|
||||||
|
|
||||||
proc select*(m: MultisteamSelect,
|
proc select*(m: MultisteamSelect,
|
||||||
|
|
Loading…
Reference in New Issue