Skip to content

Commit c08b640

Browse files
petaraschmahmann
authored andcommitted
use b36 keys by default for keys and IPNS
1 parent 692e9f5 commit c08b640

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

core/commands/keystore.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var keyGenCmd = &cmds.Command{
7777
Options: []cmds.Option{
7878
cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519").WithDefault("rsa"),
7979
cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"),
80-
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b58mh"),
80+
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
8181
},
8282
Arguments: []cmds.Argument{
8383
cmds.StringArg("name", true, false, "name of key to create"),
@@ -293,7 +293,7 @@ var keyListCmd = &cmds.Command{
293293
},
294294
Options: []cmds.Option{
295295
cmds.BoolOption("l", "Show extra information about keys."),
296-
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b58mh"),
296+
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
297297
},
298298
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
299299
if err := verifyIDFormatLabel(req.Options[keyFormatOptionName].(string)); err != nil {

core/commands/resolve.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,6 @@ Resolve the value of an IPFS DAG path:
8282
name := req.Arguments[0]
8383
recursive, _ := req.Options[resolveRecursiveOptionName].(bool)
8484

85-
var enc cidenc.Encoder
86-
switch {
87-
case !cmdenv.CidBaseDefined(req):
88-
// Not specified, check the path.
89-
enc, err = cmdenv.CidEncoderFromPath(name)
90-
if err == nil {
91-
break
92-
}
93-
// Nope, fallback on the default.
94-
fallthrough
95-
default:
96-
enc, err = cmdenv.GetCidEncoder(req)
97-
if err != nil {
98-
return err
99-
}
100-
}
101-
10285
// the case when ipns is resolved step by step
10386
if strings.HasPrefix(name, "/ipns/") && !recursive {
10487
rc, rcok := req.Options[resolveDhtRecordCountOptionName].(uint)
@@ -128,6 +111,23 @@ Resolve the value of an IPFS DAG path:
128111
return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: ipfspath.Path(p.String())})
129112
}
130113

114+
var enc cidenc.Encoder
115+
switch {
116+
case !cmdenv.CidBaseDefined(req) && !strings.HasPrefix(name, "/ipns/"):
117+
// Not specified, check the path.
118+
enc, err = cmdenv.CidEncoderFromPath(name)
119+
if err == nil {
120+
break
121+
}
122+
// Nope, fallback on the default.
123+
fallthrough
124+
default:
125+
enc, err = cmdenv.GetCidEncoder(req)
126+
if err != nil {
127+
return err
128+
}
129+
}
130+
131131
// else, ipfs path or ipns with recursive flag
132132
rp, err := api.ResolvePath(req.Context, path.New(name))
133133
if err != nil {

test/sharness/t0160-resolve.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ test_expect_success "resolve: prepare dag" '
2222
'
2323

2424
test_expect_success "resolve: prepare keys" '
25-
self_hash=$(ipfs id -f="<id>") &&
26-
alt_hash=$(ipfs key gen -f=b58mh -t rsa alt)
25+
self_hash=$(ipfs key list -f=b36cid -l | grep self | cut -d " " -f1) &&
26+
alt_hash=$(ipfs key gen -f=b36cid -t rsa alt)
27+
echo self_hash $self_hash
28+
echo $(ipfs id -f="<id>")
2729
'
2830

2931
test_resolve_setup_name() {
@@ -60,6 +62,7 @@ test_resolve() {
6062
}
6163

6264
test_resolve_cmd() {
65+
echo '-- starting test_resolve_cmd'
6366
test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash"
6467
test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash"
6568
test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash"
@@ -96,6 +99,7 @@ test_resolve_cmd() {
9699
}
97100

98101
test_resolve_cmd_b32() {
102+
echo '-- starting test_resolve_cmd_b32'
99103
# no flags needed, base should be preserved
100104

101105
test_resolve "/ipfs/$a_hash_b32" "/ipfs/$a_hash_b32"

0 commit comments

Comments
 (0)