resolver

package
v0.0.0-...-e23051b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2023 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Overview

Package resolver implements utilities for resolving paths within ipfs.

Index

Constants

This section is empty.

Variables

View Source
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 ErrNoLink struct {
	Name string
	Node cid.Cid
}

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

func (ErrNoLink) Error

func (e ErrNoLink) Error() string

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

type Resolver

type Resolver interface {
	// 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.
	ResolveToLastNode(ctx context.Context, fpath path.Path) (cid.Cid, []string, error)
	// 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.
	ResolvePath(ctx context.Context, fpath path.Path) (ipld.Node, ipld.Link, 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 via a selector traversal
	ResolvePathComponents(ctx context.Context, fpath path.Path) ([]ipld.Node, error)
}

Resolver provides path resolution to IPFS.

func NewBasicResolver

func NewBasicResolver(fetcherFactory fetcher.Factory) Resolver

NewBasicResolver constructs a new basic resolver.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL