From 18b97655254ae3aff8a5fbf8d00e488f2cb3351c Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Sat, 31 Aug 2019 13:07:00 -0600 Subject: [PATCH] fix: cleaning up based on jangko review --- libp2p/identify.nim | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libp2p/identify.nim b/libp2p/identify.nim index 2c90f13bb..cf619938c 100644 --- a/libp2p/identify.nim +++ b/libp2p/identify.nim @@ -31,6 +31,7 @@ type observedAddr*: MultiAddress protoVersion*: string agentVersion*: string + protos*: seq[string] Identify* = ref object of LPProtocol @@ -41,8 +42,8 @@ proc encodeMsg*(peerInfo: PeerInfo, observedAddrs: Multiaddress): ProtoBuffer = for ma in peerInfo.addrs: result.write(initProtoField(2, ma.data.buffer)) - for item in peerInfo.protocols: - result.write(initProtoField(3, item)) + for proto in peerInfo.protocols: + result.write(initProtoField(3, proto)) result.write(initProtoField(4, observedAddrs.data.buffer)) @@ -56,9 +57,7 @@ proc encodeMsg*(peerInfo: PeerInfo, observedAddrs: Multiaddress): ProtoBuffer = proc decodeMsg*(buf: seq[byte]): IdentifyInfo = var pb = initProtoBuffer(buf) - var pubKey: PublicKey - if pb.getValue(1, pubKey) > -1: - result.pubKey = pubKey + discard pb.getValue(1, result.pubKey) result.addrs = newSeq[MultiAddress]() var address = newSeq[byte]() @@ -69,9 +68,9 @@ proc decodeMsg*(buf: seq[byte]): IdentifyInfo = address.setLen(0) var proto = "" - var protos: seq[string] = newSeq[string]() + # var protos: seq[string] = newSeq[string]() while pb.getString(3, proto) > 0: - protos.add(proto) + result.protos.add(proto) proto = "" # TODO: do i need to clear it up? var observableAddr = newSeq[byte]()