go-path: github.com/ipfs/go-path/resolver Index | Files

package resolver

import "github.com/ipfs/go-path/resolver"

Package resolver implements utilities for resolving paths within ipfs.

Index

Package Files

resolver.go

Variables

var ErrNoComponents = errors.New(
    "path must contain at least one component")

ErrNoComponents is used when Paths after a protocol do not contain at least one component

func ResolveSingle Uses

func ResolveSingle(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, names []string) (*ipld.Link, []string, error)

ResolveSingle simply resolves one hop of a path through a graph with no extra context (does not opaquely resolve through sharded nodes)

type ErrNoLink struct {
    Name string
    Node cid.Cid
}

ErrNoLink is returned when a link is not found in a path

func (ErrNoLink) Error Uses

func (e ErrNoLink) Error() string

Error implements the Error interface for ErrNoLink with a useful human readable message.

type ResolveOnce Uses

type ResolveOnce func(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, names []string) (*ipld.Link, []string, error)

ResolveOnce resolves path through a single node

type Resolver Uses

type Resolver struct {
    DAG ipld.NodeGetter

    ResolveOnce ResolveOnce
}

Resolver provides path resolution to IPFS It has a pointer to a DAGService, which is uses to resolve nodes. TODO: now that this is more modular, try to unify this code with the

the resolvers in namesys

func NewBasicResolver Uses

func NewBasicResolver(ds ipld.DAGService) *Resolver

NewBasicResolver constructs a new basic resolver.

func (r *Resolver) ResolveLinks(ctx context.Context, ndd ipld.Node, names []string) ([]ipld.Node, error)

ResolveLinks iteratively resolves names by walking the link hierarchy. Every node is fetched from the DAGService, resolving the next name. Returns the list of nodes forming the path, starting with ndd. This list is guaranteed never to be empty.

ResolveLinks(nd, []string{"foo", "bar", "baz"}) would retrieve "baz" in ("bar" in ("foo" in nd.Links).Links).Links

func (*Resolver) ResolvePath Uses

func (r *Resolver) ResolvePath(ctx context.Context, fpath path.Path) (ipld.Node, error)

ResolvePath fetches the node for given path. It returns the last item returned by ResolvePathComponents.

func (*Resolver) ResolvePathComponents Uses

func (r *Resolver) ResolvePathComponents(ctx context.Context, fpath path.Path) ([]ipld.Node, error)

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 (*Resolver) ResolveToLastNode Uses

func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (cid.Cid, []string, error)

ResolveToLastNode walks the given path and returns the cid of the last node referenced by the path

Package resolver imports 9 packages (graph) and is imported by 43 packages. Updated 2020-09-21. Refresh now. Tools for package owners.