mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2026-01-10 00:28:10 -05:00
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:
committed by
GitHub
parent
c788a6a3c0
commit
ec00c7fc50
@@ -12,7 +12,7 @@ import chronos, chronicles
|
||||
import ../protobuf/minprotobuf,
|
||||
../peerinfo,
|
||||
../stream/connection,
|
||||
../peer,
|
||||
../peerid,
|
||||
../crypto/crypto,
|
||||
../multiaddress,
|
||||
../protocols/protocol,
|
||||
@@ -142,16 +142,18 @@ proc identify*(p: Identify,
|
||||
|
||||
if not isNil(remotePeerInfo) and result.pubKey.isSome:
|
||||
let peer = PeerID.init(result.pubKey.get())
|
||||
if peer.isErr:
|
||||
raise newException(IdentityInvalidMsgError, $peer.error)
|
||||
else:
|
||||
# do a string comaprison of the ids,
|
||||
# because that is the only thing we
|
||||
# have in most cases
|
||||
if peer.get() != remotePeerInfo.peerId:
|
||||
trace "Peer ids don't match",
|
||||
remote = peer.get().pretty(),
|
||||
local = remotePeerInfo.id
|
||||
|
||||
# do a string comparison of the ids,
|
||||
# because that is the only thing we
|
||||
# have in most cases
|
||||
if peer != remotePeerInfo.peerId:
|
||||
trace "Peer ids don't match",
|
||||
remote = peer.pretty(),
|
||||
local = remotePeerInfo.id
|
||||
|
||||
raise newException(IdentityNoMatchError, "Peer ids don't match")
|
||||
raise newException(IdentityNoMatchError, "Peer ids don't match")
|
||||
|
||||
proc push*(p: Identify, conn: Connection) {.async.} =
|
||||
await conn.write(IdentifyPushCodec)
|
||||
|
||||
Reference in New Issue
Block a user