Commit 09472fc7 authored by Steven Allen's avatar Steven Allen

rename import of go-ipld-format from node/format to ipld

License: MIT
Signed-off-by: default avatarSteven Allen <steven@stebalien.com>
parent 9d312e2f
......@@ -11,7 +11,7 @@ import (
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
)
var log = logging.Logger("path")
......@@ -35,13 +35,13 @@ func (e ErrNoLink) Error() string {
// TODO: now that this is more modular, try to unify this code with the
// the resolvers in namesys
type Resolver struct {
DAG node.DAGService
DAG ipld.DAGService
ResolveOnce func(ctx context.Context, ds node.DAGService, nd node.Node, names []string) (*node.Link, []string, error)
ResolveOnce func(ctx context.Context, ds ipld.DAGService, nd ipld.Node, names []string) (*ipld.Link, []string, error)
}
// NewBasicResolver constructs a new basic resolver.
func NewBasicResolver(ds node.DAGService) *Resolver {
func NewBasicResolver(ds ipld.DAGService) *Resolver {
return &Resolver{
DAG: ds,
ResolveOnce: ResolveSingle,
......@@ -74,7 +74,7 @@ func SplitAbsPath(fpath Path) (*cid.Cid, []string, error) {
return c, parts[1:], nil
}
func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath Path) (node.Node, []string, error) {
func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath Path) (ipld.Node, []string, error) {
c, p, err := SplitAbsPath(fpath)
if err != nil {
return nil, nil, err
......@@ -92,7 +92,7 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath Path) (node.Node
}
switch val := val.(type) {
case *node.Link:
case *ipld.Link:
next, err := val.GetNode(ctx, r.DAG)
if err != nil {
return nil, nil, err
......@@ -109,7 +109,7 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath Path) (node.Node
// ResolvePath fetches the node for given path. It returns the last item
// returned by ResolvePathComponents.
func (s *Resolver) ResolvePath(ctx context.Context, fpath Path) (node.Node, error) {
func (s *Resolver) ResolvePath(ctx context.Context, fpath Path) (ipld.Node, error) {
// validate path
if err := fpath.IsValid(); err != nil {
return nil, err
......@@ -124,14 +124,14 @@ func (s *Resolver) ResolvePath(ctx context.Context, fpath Path) (node.Node, erro
// ResolveSingle simply resolves one hop of a path through a graph with no
// extra context (does not opaquely resolve through sharded nodes)
func ResolveSingle(ctx context.Context, ds node.DAGService, nd node.Node, names []string) (*node.Link, []string, error) {
func ResolveSingle(ctx context.Context, ds ipld.DAGService, nd ipld.Node, names []string) (*ipld.Link, []string, error) {
return nd.ResolveLink(names)
}
// ResolvePathComponents fetches the nodes for each segment of the given path.
// It uses the first path component as a hash (key) of the first node, then
// resolves all other components walking the links, with ResolveLinks.
func (s *Resolver) ResolvePathComponents(ctx context.Context, fpath Path) ([]node.Node, error) {
func (s *Resolver) ResolvePathComponents(ctx context.Context, fpath Path) ([]ipld.Node, error) {
evt := log.EventBegin(ctx, "resolvePathComponents", logging.LoggableMap{"fpath": fpath})
defer evt.Done()
......@@ -158,11 +158,11 @@ func (s *Resolver) ResolvePathComponents(ctx context.Context, fpath Path) ([]nod
//
// ResolveLinks(nd, []string{"foo", "bar", "baz"})
// would retrieve "baz" in ("bar" in ("foo" in nd.Links).Links).Links
func (s *Resolver) ResolveLinks(ctx context.Context, ndd node.Node, names []string) ([]node.Node, error) {
func (s *Resolver) ResolveLinks(ctx context.Context, ndd ipld.Node, names []string) ([]ipld.Node, error) {
evt := log.EventBegin(ctx, "resolveLinks", logging.LoggableMap{"names": names})
defer evt.Done()
result := make([]node.Node, 0, len(names)+1)
result := make([]ipld.Node, 0, len(names)+1)
result = append(result, ndd)
nd := ndd // dup arg workaround
......
......@@ -10,7 +10,7 @@ import (
path "github.com/ipfs/go-ipfs/path"
util "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
)
func randNode() *merkledag.ProtoNode {
......@@ -38,7 +38,7 @@ func TestRecurivePathResolution(t *testing.T) {
t.Fatal(err)
}
for _, n := range []node.Node{a, b, c} {
for _, n := range []ipld.Node{a, b, c} {
err = dagService.Add(ctx, n)
if err != nil {
t.Fatal(err)
......
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