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