Skip to content

Commit

Permalink
feat(core): expose IpfsNode.Resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Tiger Chow committed Jan 11, 2015
1 parent cd00ddd commit 98181e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -262,6 +263,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 {
Expand Down
6 changes: 2 additions & 4 deletions core/io/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 98181e6

Please sign in to comment.