This repository has been archived by the owner on Jun 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add id and key formatting utils; format keys as b36cid by default; up…
…date tests
- Loading branch information
1 parent
d736047
commit c604c5b
Showing
4 changed files
with
67 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package iface | ||
|
||
import ( | ||
peer "github.com/libp2p/go-libp2p-core/peer" | ||
mbase "github.com/multiformats/go-multibase" | ||
) | ||
|
||
func FormatKeyID(id peer.ID) string { | ||
if s, err := peer.ToCid(id).StringOfBase(mbase.Base36); err != nil { | ||
panic(err) | ||
} else { | ||
return s | ||
} | ||
} | ||
|
||
// FormatKey formats the given IPNS key in a canonical way. | ||
func FormatKey(key Key) string { | ||
return FormatKeyID(key.ID()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters