Commit 9ed44165 authored by Steven Allen's avatar Steven Allen

use new ExtractPublicKey signature

The new version returns an error if it fails to extract the public key, instead
of just `nil, nil`. This is significantly more "go-like" and less likely to
cause confusion.
parent da17c15c
...@@ -73,13 +73,10 @@ func EmbedPublicKey(pk ic.PubKey, entry *pb.IpnsEntry) error { ...@@ -73,13 +73,10 @@ func EmbedPublicKey(pk ic.PubKey, entry *pb.IpnsEntry) error {
if err != nil { if err != nil {
return err return err
} }
extracted, err := id.ExtractPublicKey() if _, err := id.ExtractPublicKey(); err != peer.ErrNoPublicKey {
if err != nil { // Either a *real* error or nil.
return err return err
} }
if extracted != nil {
return nil
}
// We failed to extract the public key from the peer ID, embed it in the // We failed to extract the public key from the peer ID, embed it in the
// record. // record.
......
...@@ -26,20 +26,20 @@ ...@@ -26,20 +26,20 @@
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3", "hash": "QmTRhk7cgjUf2gfQ3p2M9KPECNZEW9XUrmHcFCgog4cPgB",
"name": "go-libp2p-peer", "name": "go-libp2p-peer",
"version": "2.3.8" "version": "2.4.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE", "hash": "QmatE2nxsAaK96jxMFBPMtVJEsaMrcJ21UYBHpXTkEM95r",
"name": "go-libp2p-peerstore", "name": "go-libp2p-peerstore",
"version": "2.0.4" "version": "2.0.5"
}, },
{ {
"hash": "QmSb4B8ZAAj5ALe9LjfzPyF8Ma6ezC1NTnDF2JQPUJxEXb", "hash": "Qma9Eqp16mNHDX1EL73pcxhFfzbyXVcAYtaDd1xdmDRDtL",
"name": "go-libp2p-record", "name": "go-libp2p-record",
"version": "4.1.7" "version": "4.1.8"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
......
...@@ -61,12 +61,12 @@ func (v Validator) Validate(key string, value []byte) error { ...@@ -61,12 +61,12 @@ func (v Validator) Validate(key string, value []byte) error {
} }
func (v Validator) getPublicKey(pid peer.ID, entry *pb.IpnsEntry) (ic.PubKey, error) { func (v Validator) getPublicKey(pid peer.ID, entry *pb.IpnsEntry) (ic.PubKey, error) {
pk, err := ExtractPublicKey(pid, entry) switch pk, err := ExtractPublicKey(pid, entry); err {
if err != nil { case peer.ErrNoPublicKey:
return nil, err case nil:
}
if pk != nil {
return pk, nil return pk, nil
default:
return nil, err
} }
if v.KeyBook == nil { if v.KeyBook == nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment