Skip to content

Commit

Permalink
Merge pull request ipfs/go-ipns#17 from ipfs/fix/extract-public-key
Browse files Browse the repository at this point in the history
use new ExtractPublicKey signature

This commit was moved from ipfs/go-ipns@d73bc7a
  • Loading branch information
Stebalien authored Oct 16, 2018
2 parents 093d964 + 2623cc4 commit 04299c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
7 changes: 2 additions & 5 deletions ipns/ipns.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,10 @@ func EmbedPublicKey(pk ic.PubKey, entry *pb.IpnsEntry) error {
if err != nil {
return err
}
extracted, err := id.ExtractPublicKey()
if err != nil {
if _, err := id.ExtractPublicKey(); err != peer.ErrNoPublicKey {
// Either a *real* error or nil.
return err
}
if extracted != nil {
return nil
}

// We failed to extract the public key from the peer ID, embed it in the
// record.
Expand Down
10 changes: 5 additions & 5 deletions ipns/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
pk, err := ExtractPublicKey(pid, entry)
if err != nil {
return nil, err
}
if pk != nil {
switch pk, err := ExtractPublicKey(pid, entry); err {
case peer.ErrNoPublicKey:
case nil:
return pk, nil
default:
return nil, err
}

if v.KeyBook == nil {
Expand Down

0 comments on commit 04299c0

Please sign in to comment.