mirror of https://github.com/vacp2p/nim-libp2p.git
reverting connection changes
This commit is contained in:
parent
a92d616a3e
commit
a35ecc6227
|
@ -25,7 +25,6 @@ type
|
||||||
peerInfo*: PeerInfo
|
peerInfo*: PeerInfo
|
||||||
stream*: LPStream
|
stream*: LPStream
|
||||||
observedAddrs*: Multiaddress
|
observedAddrs*: Multiaddress
|
||||||
maxReadSize: int
|
|
||||||
|
|
||||||
InvalidVarintException = object of LPStreamError
|
InvalidVarintException = object of LPStreamError
|
||||||
InvalidVarintSizeException = object of LPStreamError
|
InvalidVarintSizeException = object of LPStreamError
|
||||||
|
@ -36,12 +35,11 @@ proc newInvalidVarintException*(): ref InvalidVarintException =
|
||||||
proc newInvalidVarintSizeException*(): ref InvalidVarintSizeException =
|
proc newInvalidVarintSizeException*(): ref InvalidVarintSizeException =
|
||||||
newException(InvalidVarintSizeException, "Wrong varint size")
|
newException(InvalidVarintSizeException, "Wrong varint size")
|
||||||
|
|
||||||
proc init*[T: Connection](self: var T, stream: LPStream, maxReadSize = DefaultReadSize) =
|
proc init*[T: Connection](self: var T, stream: LPStream) =
|
||||||
## create a new Connection for the specified async reader/writer
|
## create a new Connection for the specified async reader/writer
|
||||||
new self
|
new self
|
||||||
self.stream = stream
|
self.stream = stream
|
||||||
self.closeEvent = newAsyncEvent()
|
self.closeEvent = newAsyncEvent()
|
||||||
self.maxReadSize = maxReadSize
|
|
||||||
|
|
||||||
# bind stream's close event to connection's close
|
# bind stream's close event to connection's close
|
||||||
# to ensure correct close propagation
|
# to ensure correct close propagation
|
||||||
|
@ -133,7 +131,7 @@ proc readLp*(s: Connection): Future[seq[byte]] {.async, gcsafe.} =
|
||||||
break
|
break
|
||||||
if res != VarintStatus.Success:
|
if res != VarintStatus.Success:
|
||||||
raise newInvalidVarintException()
|
raise newInvalidVarintException()
|
||||||
if size.int > s.maxReadSize:
|
if size.int > DefaultReadSize:
|
||||||
raise newInvalidVarintSizeException()
|
raise newInvalidVarintSizeException()
|
||||||
buff.setLen(size)
|
buff.setLen(size)
|
||||||
if size > 0.uint:
|
if size > 0.uint:
|
||||||
|
|
Loading…
Reference in New Issue