raise correct LP exception on incomplete data
This commit is contained in:
parent
ba843f4091
commit
6086038b01
|
@ -8,9 +8,12 @@
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import chronos, options
|
import chronos, options
|
||||||
import peerinfo, multiaddress,
|
import peerinfo,
|
||||||
stream/lpstream, peerinfo,
|
multiaddress,
|
||||||
varint, vbuffer
|
stream/lpstream,
|
||||||
|
peerinfo,
|
||||||
|
varint,
|
||||||
|
vbuffer
|
||||||
|
|
||||||
const DefaultReadSize*: uint = 64 * 1024
|
const DefaultReadSize*: uint = 64 * 1024
|
||||||
|
|
||||||
|
@ -96,9 +99,11 @@ proc readLp*(s: Connection): Future[seq[byte]] {.async, gcsafe.} =
|
||||||
result = buffer
|
result = buffer
|
||||||
return
|
return
|
||||||
buffer.setLen(size)
|
buffer.setLen(size)
|
||||||
await s.readExactly(addr buffer[0], int(size))
|
if size > 0.uint:
|
||||||
|
await s.readExactly(addr buffer[0], int(size))
|
||||||
except TransportIncompleteError:
|
except TransportIncompleteError:
|
||||||
buffer.setLen(0)
|
buffer.setLen(0)
|
||||||
|
raise newLPStreamIncompleteError()
|
||||||
|
|
||||||
result = buffer
|
result = buffer
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue