allow ipfs name resolve to respect --local flag for local name resolution
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Oct 12, 2015 at 11:36 UTC
73cd3f6563b9934d4ffc860f0168fad9a9610ca0
1 file changed
+7
-1
core/commands/ipns.go
+7
-1
@@ -7,6 +7,7 @@ import (
7
8
cmds "github.com/ipfs/go-ipfs/commands"
9
namesys "github.com/ipfs/go-ipfs/namesys"
10
+ offline "github.com/ipfs/go-ipfs/routing/offline"
11
u "github.com/ipfs/go-ipfs/util"
12
)
13
@@ -61,6 +62,11 @@ Resolve the value of another name:
62
}
63
}
64
65
+ router := n.Routing
66
+ if local, _, _ := req.Option("local").Bool(); local {
67
+ router = offline.NewOfflineRouter(n.Repo.Datastore(), n.PrivateKey)
68
+ }
69
+
70
var name string
71
72
if len(req.Arguments()) == 0 {
@@ -80,7 +86,7 @@ Resolve the value of another name:
86
depth = namesys.DefaultDepthLimit
87
}
88
83
- resolver := namesys.NewRoutingResolver(n.Routing)
89
+ resolver := namesys.NewRoutingResolver(router)
90
output, err := resolver.ResolveN(req.Context(), name, depth)
91
if err != nil {
92
res.SetError(err, cmds.ErrNormal)