reverting connection changes

This commit is contained in:
Dmitriy Ryajov 2020-03-27 10:03:17 -06:00
parent a92d616a3e
commit a35ecc6227
1 changed files with 2 additions and 4 deletions

View File

@ -25,7 +25,6 @@ type
peerInfo*: PeerInfo
stream*: LPStream
observedAddrs*: Multiaddress
maxReadSize: int
InvalidVarintException = object of LPStreamError
InvalidVarintSizeException = object of LPStreamError
@ -36,12 +35,11 @@ proc newInvalidVarintException*(): ref InvalidVarintException =
proc newInvalidVarintSizeException*(): ref InvalidVarintSizeException =
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
new self
self.stream = stream
self.closeEvent = newAsyncEvent()
self.maxReadSize = maxReadSize
# bind stream's close event to connection's close
# to ensure correct close propagation
@ -133,7 +131,7 @@ proc readLp*(s: Connection): Future[seq[byte]] {.async, gcsafe.} =
break
if res != VarintStatus.Success:
raise newInvalidVarintException()
if size.int > s.maxReadSize:
if size.int > DefaultReadSize:
raise newInvalidVarintSizeException()
buff.setLen(size)
if size > 0.uint: