adding bool

This commit is contained in:
Dmitriy Ryajov 2019-09-11 13:06:22 -06:00
parent 67e10d0747
commit 003b72ec27
1 changed files with 4 additions and 5 deletions

View File

@ -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())