From 003b72ec27001444600acca696cacd329ee7a663 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Wed, 11 Sep 2019 13:06:22 -0600 Subject: [PATCH] adding bool --- libp2p/connection.nim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libp2p/connection.nim b/libp2p/connection.nim index c66874244..854b92082 100644 --- a/libp2p/connection.nim +++ b/libp2p/connection.nim @@ -19,17 +19,16 @@ const DefaultReadSize*: uint = 64 * 1024 type Connection* = ref object of LPStream - peerInfo*: Option[PeerInfo] + peerInfo*: PeerInfo stream*: LPStream proc newConnection*(stream: LPStream): Connection = ## create a new Connection for the specified async reader/writer new result result.stream = stream - result.peerInfo = none(PeerInfo) proc `=peerInfo`*(s: Connection, peerInfo: PeerInfo) = - s.peerInfo = some(peerInfo) + s.peerInfo = peerInfo method read*(s: Connection, n = -1): Future[seq[byte]] {.gcsafe.} = result = s.stream.read(n) @@ -119,5 +118,5 @@ method getObservedAddrs*(c: Connection): Future[MultiAddress] {.base, async, gcs discard proc `$`*(conn: Connection): string = - if conn.peerInfo.isSome: - result = $(conn.peerInfo.get().peerId) + if conn.peerInfo.peerId.isSome: + result = $(conn.peerInfo.peerId.get())