Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Make nodeID calculation pluggable #27

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var log = logging.Logger("peer")

type ID string

var PluggableIDFromPublicKey = DefaultIDFromPublicKey

// Pretty returns a b58-encoded string of the ID
func (id ID) Pretty() string {
return IDB58Encode(id)
Expand Down Expand Up @@ -187,6 +189,10 @@ func IDHexEncode(id ID) string {

// IDFromPublicKey returns the Peer ID corresponding to pk
func IDFromPublicKey(pk ic.PubKey) (ID, error) {
return PluggableIDFromPublicKey(pk)
}

func DefaultIDFromPublicKey(pk ic.PubKey) (ID, error) {
b, err := pk.Bytes()
if err != nil {
return "", err
Expand Down