@cryptotaxi247 / kubo / commits / aea52132c

cmd/ipfs: Initialize IpfsNode when running locally or starting daemon

Matt Bell committed Oct 28, 2014 at 23:10 UTC aea52132cb9a4fcb20e8f9bb53f4918227b4391b
2 files changed +16 -3
cmd/ipfs/daemon.go
+8 -2
@@ -9,6 +9,7 @@ import (
9
10 cmds "github.com/jbenet/go-ipfs/commands"
11 cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
12 + "github.com/jbenet/go-ipfs/core"
13 "github.com/jbenet/go-ipfs/daemon"
14 )
15
@@ -20,10 +21,15 @@ var Daemon = &cmds.Command{
21 }
22
23 func daemonFunc(req cmds.Request, res cmds.Response) {
23 - // TODO: spin up a core.IpfsNode
24 -
24 ctx := req.Context()
25
26 + node, err := core.NewIpfsNode(ctx.Config, true)
27 + if err != nil {
28 + res.SetError(err, cmds.ErrNormal)
29 + return
30 + }
31 + ctx.Node = node
32 +
33 lk, err := daemon.Lock(ctx.ConfigRoot)
34 if err != nil {
35 res.SetError(fmt.Errorf("Couldn't obtain lock. Is another daemon already running?"), cmds.ErrNormal)
cmd/ipfs/ipfs.go
+8 -1
@@ -10,6 +10,7 @@ import (
10 cmdsCli "github.com/jbenet/go-ipfs/commands/cli"
11 cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
12 "github.com/jbenet/go-ipfs/config"
13 + "github.com/jbenet/go-ipfs/core"
14 "github.com/jbenet/go-ipfs/core/commands"
15 "github.com/jbenet/go-ipfs/daemon"
16 u "github.com/jbenet/go-ipfs/util"
@@ -110,7 +111,13 @@ func main() {
111 }
112
113 } else {
113 - // TODO: spin up node
114 + node, err := core.NewIpfsNode(conf, false)
115 + if err != nil {
116 + fmt.Println(err)
117 + os.Exit(1)
118 + }
119 + ctx.Node = node
120 +
121 res = root.Call(req)
122 }
123 }