mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 09:34:03 +08:00
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
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
|
||||
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
|
||||
cmds "github.com/jbenet/go-ipfs/commands"
|
||||
"github.com/jbenet/go-ipfs/core"
|
||||
commands "github.com/jbenet/go-ipfs/core/commands"
|
||||
corehttp "github.com/jbenet/go-ipfs/core/corehttp"
|
||||
fsrepo "github.com/jbenet/go-ipfs/repo/fsrepo"
|
||||
@ -100,12 +101,15 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
|
||||
|
||||
// OK!!! Now we're ready to construct the node.
|
||||
// make sure we construct an online node.
|
||||
ctx.Online = true
|
||||
node, err := ctx.GetNode()
|
||||
node, err := core.NewIPFSNode(ctx.Context, core.Online(repo))
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
return
|
||||
}
|
||||
defer node.Close()
|
||||
req.Context().ConstructNode = func() (*core.IpfsNode, error) {
|
||||
return node, nil
|
||||
}
|
||||
|
||||
// verify api address is valid multiaddr
|
||||
apiMaddr, err := ma.NewMultiaddr(cfg.Addresses.API)
|
||||
|
Reference in New Issue
Block a user