small cleanup

This commit is contained in:
Dmitriy Ryajov 2020-04-04 20:43:05 -06:00
parent 8dda6c289d
commit bae4713a85
1 changed files with 16 additions and 15 deletions

View File

@ -16,6 +16,7 @@ import ../../peer
import ../../peerinfo import ../../peerinfo
import ../../protobuf/minprotobuf import ../../protobuf/minprotobuf
import ../../utility import ../../utility
import ../../stream/lpstream
import secure, import secure,
../../crypto/[crypto, chacha20poly1305, curve25519, hkdf], ../../crypto/[crypto, chacha20poly1305, curve25519, hkdf],
../../stream/bufferstream ../../stream/bufferstream
@ -426,9 +427,9 @@ method readMessage(sconn: NoiseConnection): Future[seq[byte]] {.async.} =
var plain = sconn.readCs.decryptWithAd([], cipher) var plain = sconn.readCs.decryptWithAd([], cipher)
unpackNoisePayload(plain) unpackNoisePayload(plain)
return plain return plain
except AsyncStreamIncompleteError: except LPStreamIncompleteError:
trace "Connection dropped while reading" trace "Connection dropped while reading"
except AsyncStreamReadError: except LPStreamReadError:
trace "Error reading from connection" trace "Error reading from connection"
method writeMessage(sconn: NoiseConnection, message: seq[byte]): Future[void] {.async.} = method writeMessage(sconn: NoiseConnection, message: seq[byte]): Future[void] {.async.} =
@ -508,7 +509,7 @@ method handshake*(p: Noise, conn: Connection, initiator: bool = false): Future[S
secure.readCs = handshakeRes.cs1 secure.readCs = handshakeRes.cs1
secure.writeCs = handshakeRes.cs2 secure.writeCs = handshakeRes.cs2
debug "Noise handshake completed!" trace "Noise handshake completed!"
return secure return secure