From 686c1736fd35410e21ff4cc3fa5e566452c02c1c Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Wed, 14 Aug 2019 14:27:04 -0700 Subject: [PATCH] Compare multihash `Code` to `IDENTITY` when extracting public key This PR is a non-substantive change with the goal of making this method `ExtractPublicKey` from a `peer.ID` clearer to the reader. This goal is accomplished by using the full name of the identity hash code `IDENTITY` instead of the deprecated `ID` code. This change makes its clearer to the reader that there is a trivial way to compute the public key given the digest. Without this change it is easy to confuse `ID` with a concept relating to peer IDs (and thus implying this function somehow computes a hash pre-image to get the corrresponding public key. --- peer/peer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/peer/peer.go b/peer/peer.go index db307ee..edef635 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -92,7 +92,7 @@ func (id ID) ExtractPublicKey() (ic.PubKey, error) { if err != nil { return nil, err } - if decoded.Code != mh.ID { + if decoded.Code != mh.IDENTITY { return nil, ErrNoPublicKey } pk, err := ic.UnmarshalPublicKey(decoded.Digest)