mirror of
https://github.com/codex-storage/nim-libp2p.git
synced 2025-01-11 19:44:18 +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
|
||||
lesize = buf.len.uint16
|
||||
besize = lesize.toBytesBE
|
||||
outbuf = newSeqOfCap[byte](besize.len + buf.len)
|
||||
trace "sendHSMessage", size = lesize
|
||||
await sconn.write(besize[0].addr, besize.len)
|
||||
await sconn.write(buf)
|
||||
outbuf &= besize
|
||||
outbuf &= buf
|
||||
await sconn.write(outbuf)
|
||||
|
||||
proc packNoisePayload(payload: openarray[byte]): seq[byte] =
|
||||
let
|
||||
|
Loading…
x
Reference in New Issue
Block a user