Avoid 2 async consecutive writes in noise HS

This commit is contained in:
Giovanni Petrantoni 2020-03-18 20:40:51 +09:00
parent c02fca25f8
commit b1a34f478e
1 changed files with 4 additions and 2 deletions

View File

@ -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