Peer resultification and defect only (#245)

* Peer resultification and defect only

* Fixing some tests

* test fixes

* Rename peer into peerid

* better result error message in identify

* further merge fixes
This commit is contained in:
Giovanni Petrantoni
2020-07-01 15:25:09 +09:00
committed by GitHub
parent c788a6a3c0
commit ec00c7fc50
29 changed files with 103 additions and 83 deletions

View File

@@ -12,7 +12,7 @@ import chronicles
import stew/[endians2, byteutils]
import nimcrypto/[utils, sysrand, sha2, hmac]
import ../../stream/lpstream
import ../../peer
import ../../peerid
import ../../peerinfo
import ../../protobuf/minprotobuf
import ../../utility
@@ -460,7 +460,7 @@ method handshake*(p: Noise, conn: Connection, initiator: bool): Future[SecureCon
let pid = PeerID.init(remotePubKey)
if not conn.peerInfo.peerId.validate():
raise newException(NoiseHandshakeError, "Failed to validate peerId.")
if pid != conn.peerInfo.peerId:
if pid.isErr or pid.get() != conn.peerInfo.peerId:
var
failedKey: PublicKey
discard extractPublicKey(conn.peerInfo.peerId, failedKey)