Commit 033e33da authored by Brian Tiger Chow's avatar Brian Tiger Chow

feat(core): expose IpfsNode.Resolve

parent 223ee4df
......@@ -29,6 +29,7 @@ import (
pin "github.com/jbenet/go-ipfs/pin"
routing "github.com/jbenet/go-ipfs/routing"
dht "github.com/jbenet/go-ipfs/routing/dht"
util "github.com/jbenet/go-ipfs/util"
ds2 "github.com/jbenet/go-ipfs/util/datastore2"
debugerror "github.com/jbenet/go-ipfs/util/debugerror"
eventlog "github.com/jbenet/go-ipfs/util/eventlog"
......@@ -264,6 +265,10 @@ func (n *IpfsNode) OnlineMode() bool {
}
}
func (n *IpfsNode) Resolve(k util.Key) (*merkledag.Node, error) {
return (&path.Resolver{n.DAG}).ResolvePath(k.String())
}
func (n *IpfsNode) Bootstrap(ctx context.Context, peers []peer.PeerInfo) error {
if n.DHT != nil {
for _, p := range peers {
......
......@@ -15,16 +15,14 @@ import (
"io"
core "github.com/jbenet/go-ipfs/core"
path "github.com/jbenet/go-ipfs/path"
uio "github.com/jbenet/go-ipfs/unixfs/io"
u "github.com/jbenet/go-ipfs/util"
)
func Cat(n *core.IpfsNode, k u.Key) (io.Reader, error) {
dag := n.DAG
dagNode, err := (&path.Resolver{dag}).ResolvePath(k.String())
dagNode, err := n.Resolve(k)
if err != nil {
return nil, err
}
return uio.NewDagReader(dagNode, dag)
return uio.NewDagReader(dagNode, n.DAG)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment