mirror of
https://github.com/vacp2p/nim-libp2p-experimental.git
synced 2025-01-11 19:04:26 +00:00
Avoid 2 async consecutive writes in noise HS
This commit is contained in:
parent
c02fca25f8
commit
b1a34f478e
@ -273,9 +273,11 @@ proc sendHSMessage(sconn: Connection; buf: seq[byte]) {.async.} =
|
|||||||
var
|
var
|
||||||
lesize = buf.len.uint16
|
lesize = buf.len.uint16
|
||||||
besize = lesize.toBytesBE
|
besize = lesize.toBytesBE
|
||||||
|
outbuf = newSeqOfCap[byte](besize.len + buf.len)
|
||||||
trace "sendHSMessage", size = lesize
|
trace "sendHSMessage", size = lesize
|
||||||
await sconn.write(besize[0].addr, besize.len)
|
outbuf &= besize
|
||||||
await sconn.write(buf)
|
outbuf &= buf
|
||||||
|
await sconn.write(outbuf)
|
||||||
|
|
||||||
proc packNoisePayload(payload: openarray[byte]): seq[byte] =
|
proc packNoisePayload(payload: openarray[byte]): seq[byte] =
|
||||||
let
|
let
|
||||||
|
Loading…
x
Reference in New Issue
Block a user