generated from ipfs/ipfs-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ipfs/interface-go-ipfs-core#65 from ipfs/petar/nam…
…efmt Add ID formatting functions, used by various IPFS cli commands This commit was moved from ipfs/interface-go-ipfs-core@b935dfe
- Loading branch information
Showing
3 changed files
with
66 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
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