mirror of https://github.com/vacp2p/nim-libp2p.git
adding bool
This commit is contained in:
parent
67e10d0747
commit
003b72ec27
|
@ -19,17 +19,16 @@ const DefaultReadSize*: uint = 64 * 1024
|
||||||
|
|
||||||
type
|
type
|
||||||
Connection* = ref object of LPStream
|
Connection* = ref object of LPStream
|
||||||
peerInfo*: Option[PeerInfo]
|
peerInfo*: PeerInfo
|
||||||
stream*: LPStream
|
stream*: LPStream
|
||||||
|
|
||||||
proc newConnection*(stream: LPStream): Connection =
|
proc newConnection*(stream: LPStream): Connection =
|
||||||
## create a new Connection for the specified async reader/writer
|
## create a new Connection for the specified async reader/writer
|
||||||
new result
|
new result
|
||||||
result.stream = stream
|
result.stream = stream
|
||||||
result.peerInfo = none(PeerInfo)
|
|
||||||
|
|
||||||
proc `=peerInfo`*(s: Connection, peerInfo: PeerInfo) =
|
proc `=peerInfo`*(s: Connection, peerInfo: PeerInfo) =
|
||||||
s.peerInfo = some(peerInfo)
|
s.peerInfo = peerInfo
|
||||||
|
|
||||||
method read*(s: Connection, n = -1): Future[seq[byte]] {.gcsafe.} =
|
method read*(s: Connection, n = -1): Future[seq[byte]] {.gcsafe.} =
|
||||||
result = s.stream.read(n)
|
result = s.stream.read(n)
|
||||||
|
@ -119,5 +118,5 @@ method getObservedAddrs*(c: Connection): Future[MultiAddress] {.base, async, gcs
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc `$`*(conn: Connection): string =
|
proc `$`*(conn: Connection): string =
|
||||||
if conn.peerInfo.isSome:
|
if conn.peerInfo.peerId.isSome:
|
||||||
result = $(conn.peerInfo.get().peerId)
|
result = $(conn.peerInfo.peerId.get())
|
||||||
|
|
Loading…
Reference in New Issue