From 5ae37cac9830ca5045a116b36c38cbf72e1cd7d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Wed, 25 Sep 2019 12:53:31 -0600 Subject: [PATCH] no more buffer resets on len prefixed reads --- libp2p/connection.nim | 1 - libp2p/muxers/mplex/coder.nim | 1 - 2 files changed, 2 deletions(-) diff --git a/libp2p/connection.nim b/libp2p/connection.nim index 460a0fc1f..9ae61e21f 100644 --- a/libp2p/connection.nim +++ b/libp2p/connection.nim @@ -92,7 +92,6 @@ proc readLp*(s: Connection): Future[seq[byte]] {.async, gcsafe.} = if res == VarintStatus.Success: break if res != VarintStatus.Success or size > DefaultReadSize: - buffer.setLen(0) result = buffer return buffer.setLen(size) diff --git a/libp2p/muxers/mplex/coder.nim b/libp2p/muxers/mplex/coder.nim index acf4f9c3c..af406a436 100644 --- a/libp2p/muxers/mplex/coder.nim +++ b/libp2p/muxers/mplex/coder.nim @@ -38,7 +38,6 @@ proc readMplexVarint(conn: Connection): Future[Option[uint]] {.async, gcsafe.} = if res == VarintStatus.Success: return some(varint) if res != VarintStatus.Success: - buffer.setLen(0) return except LPStreamIncompleteError: debug "unable to read varing", exc = getCurrentExceptionMsg()