Documentation ¶
Overview ¶
Package resolver implements utilities for resolving paths within ipfs.
Index ¶
- Variables
- func ResolveSingle(ctx context.Context, ds format.NodeGetter, nd format.Node, names []string) (*format.Link, []string, error)
- type ErrNoLink
- type Resolver
- func (r *Resolver) ResolveLinks(ctx context.Context, ndd ipld.Node, names []string) ([]ipld.Node, error)
- func (r *Resolver) ResolvePath(ctx context.Context, fpath path.Path) (ipld.Node, ipld.Link, error)
- func (r *Resolver) ResolvePathComponents(ctx context.Context, fpath path.Path) ([]ipld.Node, error)
- func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (cid.Cid, []string, error)
Constants ¶
This section is empty.
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
Functions ¶
func ResolveSingle ¶
func ResolveSingle(ctx context.Context, ds format.NodeGetter, nd format.Node, names []string) (*format.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) Deprecated: fetch node as ipld-prime or convert it and then use a selector to traverse through it.
Types ¶
type Resolver ¶
type Resolver struct {
FetcherFactory fetcher.Factory
}
Resolver provides path resolution to IPFS It references a FetcherFactory, 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 ¶
func NewBasicResolver(fetcherFactory fetcher.Factory) *Resolver
NewBasicResolver constructs a new basic resolver.
func (*Resolver) ResolveLinks ¶
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 Fetcher, 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
Note: if/when the context is cancelled or expires then if a multi-block ADL node is returned then it may not be possible to load certain values.
func (*Resolver) ResolvePath ¶
ResolvePath fetches the node for given path. It returns the last item returned by ResolvePathComponents and the last link traversed which can be used to recover the block.
Note: if/when the context is cancelled or expires then if a multi-block ADL node is returned then it may not be possible to load certain values.
func (*Resolver) ResolvePathComponents ¶
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 via a selector traversal
Note: if/when the context is cancelled or expires then if a multi-block ADL node is returned then it may not be possible to load certain values.
func (*Resolver) ResolveToLastNode ¶
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 block referenced by the path, and the path segments to traverse from the final block boundary to the final node within the block.