-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
324 additions
and
239 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,33 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
peer "github.com/libp2p/go-libp2p-core/peer" | ||
mbase "github.com/multiformats/go-multibase" | ||
) | ||
|
||
func verifyIDFormatLabel(formatLabel string) error { | ||
switch formatLabel { | ||
case "b58mh": | ||
return nil | ||
case "b36cid": | ||
return nil | ||
} | ||
return fmt.Errorf("invalid output format option") | ||
} | ||
|
||
func formatID(id peer.ID, formatLabel string) string { | ||
switch formatLabel { | ||
case "b58mh": | ||
return id.Pretty() | ||
case "b36cid": | ||
if s, err := peer.ToCid(id).StringOfBase(mbase.Base36); err != nil { | ||
panic(err) | ||
} else { | ||
return s | ||
} | ||
default: | ||
panic("unreachable") | ||
} | ||
} |
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
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
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
Oops, something went wrong.