Merge pull request #34 from libp2p/no-key-error-check

make the error check for not receiving a public key more explicit
This commit is contained in:
Steven Allen 2019-11-11 16:06:40 -08:00 committed by GitHub
commit 7c0aea2417
1 changed files with 3 additions and 4 deletions

View File

@ -116,6 +116,9 @@ func (t *Transport) handshake(
case remotePubKey = <-keyCh:
default:
}
if remotePubKey == nil {
return nil, errors.New("go-libp2p-tls BUG: expected remote pub key to be set")
}
conn, err := t.setupConn(tlsConn, remotePubKey)
if err != nil {
@ -129,10 +132,6 @@ func (t *Transport) handshake(
}
func (t *Transport) setupConn(tlsConn *tls.Conn, remotePubKey ci.PubKey) (sec.SecureConn, error) {
if remotePubKey == nil {
return nil, errors.New("go-libp2p-tls BUG: expected remote pub key to be set")
}
remotePeerID, err := peer.IDFromPublicKey(remotePubKey)
if err != nil {
return nil, err