提交 c1560bef 作者: Jeromy

fix up core.Resolve a bit

上级 e3255f46
...@@ -8,7 +8,6 @@ import ( ...@@ -8,7 +8,6 @@ import (
cmds "github.com/ipfs/go-ipfs/commands" cmds "github.com/ipfs/go-ipfs/commands"
core "github.com/ipfs/go-ipfs/core" core "github.com/ipfs/go-ipfs/core"
nsys "github.com/ipfs/go-ipfs/namesys"
crypto "github.com/ipfs/go-ipfs/p2p/crypto" crypto "github.com/ipfs/go-ipfs/p2p/crypto"
path "github.com/ipfs/go-ipfs/path" path "github.com/ipfs/go-ipfs/path"
u "github.com/ipfs/go-ipfs/util" u "github.com/ipfs/go-ipfs/util"
...@@ -77,6 +76,7 @@ Publish an <ipfs-path> to another public key (not implemented): ...@@ -77,6 +76,7 @@ Publish an <ipfs-path> to another public key (not implemented):
// name = args[0] // name = args[0]
pstr = args[1] pstr = args[1]
res.SetError(errors.New("keychains not yet implemented"), cmds.ErrNormal) res.SetError(errors.New("keychains not yet implemented"), cmds.ErrNormal)
return
case 1: case 1:
// name = n.Identity.ID.String() // name = n.Identity.ID.String()
pstr = args[0] pstr = args[0]
...@@ -108,14 +108,12 @@ Publish an <ipfs-path> to another public key (not implemented): ...@@ -108,14 +108,12 @@ Publish an <ipfs-path> to another public key (not implemented):
func publish(n *core.IpfsNode, k crypto.PrivKey, ref path.Path) (*IpnsEntry, error) { func publish(n *core.IpfsNode, k crypto.PrivKey, ref path.Path) (*IpnsEntry, error) {
// First, verify the path exists // First, verify the path exists
_, err := n.Resolver.ResolvePath(ref) _, err := core.Resolve(n, ref)
if err != nil { if err != nil {
return nil, err return nil, err
} }
pub := nsys.NewRoutingPublisher(n.Routing) err = n.Namesys.Publish(n.Context(), k, ref)
err = pub.Publish(n.Context(), k, ref)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -45,7 +45,11 @@ func (p Path) String() string { ...@@ -45,7 +45,11 @@ func (p Path) String() string {
} }
func FromSegments(seg ...string) Path { func FromSegments(seg ...string) Path {
return Path(strings.Join(seg, "/")) var pref string
if seg[0] == "ipfs" || seg[0] == "ipns" {
pref = "/"
}
return Path(pref + strings.Join(seg, "/"))
} }
func ParsePath(txt string) (Path, error) { func ParsePath(txt string) (Path, error) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论