提交 0c53a66d 作者: Jeromy Johnson

Merge pull request #707 from jbenet/fix/689

fix cast panic in ipfs name resolve when daemon is running
...@@ -9,6 +9,10 @@ import ( ...@@ -9,6 +9,10 @@ import (
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
) )
type ResolvedKey struct {
Key u.Key
}
var resolveCmd = &cmds.Command{ var resolveCmd = &cmds.Command{
Helptext: cmds.HelpText{ Helptext: cmds.HelpText{
Tagline: "Gets the value currently published at an IPNS name", Tagline: "Gets the value currently published at an IPNS name",
...@@ -78,12 +82,16 @@ Resolve te value of another name: ...@@ -78,12 +82,16 @@ Resolve te value of another name:
// TODO: better errors (in the case of not finding the name, we get "failed to find any peer in table") // TODO: better errors (in the case of not finding the name, we get "failed to find any peer in table")
res.SetOutput(output) res.SetOutput(&ResolvedKey{output})
}, },
Marshalers: cmds.MarshalerMap{ Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) { cmds.Text: func(res cmds.Response) (io.Reader, error) {
output := res.Output().(u.Key) output, ok := res.Output().(*ResolvedKey)
return strings.NewReader(output.B58String()), nil if !ok {
return nil, u.ErrCast()
}
return strings.NewReader(output.Key.B58String()), nil
}, },
}, },
Type: ResolvedKey{},
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论