use plain-old core.IPFSNode constructor in daemon command
fix(cmd/daemon) set node on req context since it expects daemon to be present when handling commands over the API @jbenet revenge of the request context redux
Brian Tiger Chow committed
Jan 30, 2015 at 15:32 UTC
cbed85899337da39f2ad619fcfd6300325457add
1 file changed
+6
-2
cmd/ipfs/daemon.go
+6
-2
@@ -6,6 +6,7 @@ import (
6
7
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
8
cmds "github.com/jbenet/go-ipfs/commands"
9
+ "github.com/jbenet/go-ipfs/core"
10
commands "github.com/jbenet/go-ipfs/core/commands"
11
corehttp "github.com/jbenet/go-ipfs/core/corehttp"
12
fsrepo "github.com/jbenet/go-ipfs/repo/fsrepo"
@@ -100,12 +101,15 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
101
102
// OK!!! Now we're ready to construct the node.
103
// make sure we construct an online node.
103
- ctx.Online = true
104
- node, err := ctx.GetNode()
104
+ node, err := core.NewIPFSNode(ctx.Context, core.Online(repo))
105
if err != nil {
106
res.SetError(err, cmds.ErrNormal)
107
return
108
}
109
+ defer node.Close()
110
+ req.Context().ConstructNode = func() (*core.IpfsNode, error) {
111
+ return node, nil
112
+ }
113
114
// verify api address is valid multiaddr
115
apiMaddr, err := ma.NewMultiaddr(cfg.Addresses.API)