mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-28 05:47:51 +08:00
feat(core): expose IpfsNode.Resolve
This commit is contained in:
parent
223ee4df1a
commit
033e33dadf
@ -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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user