Documentation ¶
Overview ¶
package merkledag implements the IPFS Merkle DAG datastructures.
Index ¶
- Variables
- func EnumerateChildren(ctx context.Context, getLinks GetLinks, root *cid.Cid, ...) error
- func EnumerateChildrenAsync(ctx context.Context, getLinks GetLinks, c *cid.Cid, visit func(*cid.Cid) bool) error
- func FetchGraph(ctx context.Context, root *cid.Cid, serv DAGService) error
- func FindLinks(links []*cid.Cid, c *cid.Cid, start int) []int
- func NewDAGService(bs bserv.BlockService) *dagService
- type Batch
- type DAGService
- type GetLinks
- type LinkService
- type LinkSlice
- type NodeGetter
- type NodeOption
- type ProgressTracker
- type ProtoNode
- func (n *ProtoNode) AddNodeLink(name string, that node.Node) error
- func (n *ProtoNode) AddNodeLinkClean(name string, that node.Node) error
- func (n *ProtoNode) AddRawLink(name string, l *node.Link) error
- func (n *ProtoNode) Cid() *cid.Cid
- func (n *ProtoNode) Copy() node.Node
- func (n *ProtoNode) Data() []byte
- func (n *ProtoNode) EncodeProtobuf(force bool) ([]byte, error)
- func (n *ProtoNode) GetLinkedNode(ctx context.Context, ds DAGService, name string) (node.Node, error)
- func (n *ProtoNode) GetLinkedProtoNode(ctx context.Context, ds DAGService, name string) (*ProtoNode, error)
- func (n *ProtoNode) GetNodeLink(name string) (*node.Link, error)
- func (n *ProtoNode) Links() []*node.Link
- func (n *ProtoNode) Loggable() map[string]interface{}
- func (n *ProtoNode) Marshal() ([]byte, error)
- func (n *ProtoNode) MarshalJSON() ([]byte, error)
- func (n *ProtoNode) Multihash() mh.Multihash
- func (n *ProtoNode) RawData() []byte
- func (n *ProtoNode) RemoveNodeLink(name string) error
- func (n *ProtoNode) Resolve(path []string) (interface{}, []string, error)
- func (n *ProtoNode) ResolveLink(path []string) (*node.Link, []string, error)
- func (n *ProtoNode) SetData(d []byte)
- func (n *ProtoNode) SetLinks(links []*node.Link)
- func (n *ProtoNode) Size() (uint64, error)
- func (n *ProtoNode) Stat() (*node.NodeStat, error)
- func (n *ProtoNode) String() string
- func (n *ProtoNode) Tree(p string, depth int) []string
- func (n *ProtoNode) UnmarshalJSON(b []byte) error
- func (n *ProtoNode) UpdateNodeLink(name string, that *ProtoNode) (*ProtoNode, error)
- type RawNode
- func (rn *RawNode) Copy() node.Node
- func (rn *RawNode) Links() []*node.Link
- func (rn *RawNode) Resolve(path []string) (interface{}, []string, error)
- func (rn *RawNode) ResolveLink(path []string) (*node.Link, []string, error)
- func (rn *RawNode) Size() (uint64, error)
- func (rn *RawNode) Stat() (*node.NodeStat, error)
- func (rn *RawNode) Tree(p string, depth int) []string
Constants ¶
This section is empty.
Variables ¶
var ErrLinkNotFound = fmt.Errorf("no link by that name")
var ErrNotFound = fmt.Errorf("merkledag: not found")
var ErrNotProtobuf = fmt.Errorf("expected protobuf dag node")
var FetchGraphConcurrency = 8
FetchGraphConcurrency is total number of concurrent fetches that 'fetchNodes' will start at a time
Functions ¶
func EnumerateChildren ¶ added in v0.4.0
func EnumerateChildren(ctx context.Context, getLinks GetLinks, root *cid.Cid, visit func(*cid.Cid) bool) error
EnumerateChildren will walk the dag below the given root node and add all unseen children to the passed in set. TODO: parallelize to avoid disk latency perf hits?
func EnumerateChildrenAsync ¶ added in v0.4.0
func FetchGraph ¶
FetchGraph fetches all nodes that are children of the given node
func FindLinks ¶
FindLinks searches this nodes links for the given key, returns the indexes of any links pointing to it
func NewDAGService ¶
func NewDAGService(bs bserv.BlockService) *dagService
Types ¶
type DAGService ¶
type DAGService interface { Add(node.Node) (*cid.Cid, error) Get(context.Context, *cid.Cid) (node.Node, error) Remove(node.Node) error // GetDAG returns, in order, all the single leve child // nodes of the passed in node. GetMany(context.Context, []*cid.Cid) <-chan *NodeOption Batch() *Batch LinkService }
DAGService is an IPFS Merkle DAG service.
type GetLinks ¶ added in v0.4.7
func GetLinksDirect ¶ added in v0.4.7
func GetLinksDirect(serv DAGService) GetLinks
GetLinksDirect creates a function to get the links for a node, from the node, bypassing the LinkService. If the node does not exist locally (and can not be retrieved) an error will be returned.
type LinkService ¶ added in v0.4.5
type LinkService interface { // GetLinks return all links for a node. The complete node does not // necessarily have to exist locally, or at all. For example, raw // leaves cannot possibly have links so there is no need to look // at the node. GetLinks(context.Context, *cid.Cid) ([]*node.Link, error) GetOfflineLinkService() LinkService }
type NodeGetter ¶
type NodeGetter interface { Get(context.Context) (node.Node, error) Fail(err error) Send(node.Node) }
NodeGetter provides a promise like interface for a dag Node the first call to Get will block until the Node is received from its internal channels, subsequent calls will return the cached node.
func GetDAG ¶ added in v0.4.0
func GetDAG(ctx context.Context, ds DAGService, root node.Node) []NodeGetter
GetDAG will fill out all of the links of the given Node. It returns a channel of nodes, which the caller can receive all the child nodes of 'root' on, in proper order.
func GetNodes ¶ added in v0.4.0
func GetNodes(ctx context.Context, ds DAGService, keys []*cid.Cid) []NodeGetter
GetNodes returns an array of 'NodeGetter' promises, with each corresponding to the key with the same index as the passed in keys
type NodeOption ¶ added in v0.4.0
type ProgressTracker ¶ added in v0.4.7
type ProgressTracker struct { Total int // contains filtered or unexported fields }
func (*ProgressTracker) DeriveContext ¶ added in v0.4.7
func (p *ProgressTracker) DeriveContext(ctx context.Context) context.Context
func (*ProgressTracker) Increment ¶ added in v0.4.7
func (p *ProgressTracker) Increment()
func (*ProgressTracker) Value ¶ added in v0.4.7
func (p *ProgressTracker) Value() int
type ProtoNode ¶ added in v0.4.5
type ProtoNode struct { // Prefix specifies cid version and hashing function Prefix cid.Prefix // contains filtered or unexported fields }
Node represents a node in the IPFS Merkle DAG. nodes have opaque data and a set of navigable links.
func DecodeProtobuf ¶ added in v0.4.0
Decoded decodes raw data and returns a new Node instance.
func NodeWithData ¶ added in v0.4.3
func (*ProtoNode) AddNodeLink ¶ added in v0.4.5
AddNodeLink adds a link to another node.
func (*ProtoNode) AddNodeLinkClean ¶ added in v0.4.5
AddNodeLinkClean adds a link to another node. without keeping a reference to the child node
func (*ProtoNode) AddRawLink ¶ added in v0.4.5
AddRawLink adds a copy of a link to this node
func (*ProtoNode) Copy ¶ added in v0.4.5
Copy returns a copy of the node. NOTE: Does not make copies of Node objects in the links.
func (*ProtoNode) EncodeProtobuf ¶ added in v0.4.5
EncodeProtobuf returns the encoded raw data version of a Node instance. It may use a cached encoded version, unless the force flag is given.
func (*ProtoNode) GetLinkedNode ¶ added in v0.4.5
func (*ProtoNode) GetLinkedProtoNode ¶ added in v0.4.5
func (*ProtoNode) GetNodeLink ¶ added in v0.4.5
Return a copy of the link with given name
func (*ProtoNode) Marshal ¶ added in v0.4.5
Marshal encodes a *Node instance into a new byte slice. The conversion uses an intermediate PBNode.
func (*ProtoNode) MarshalJSON ¶ added in v0.4.5
func (*ProtoNode) RemoveNodeLink ¶ added in v0.4.5
Remove a link on this node by the given name
func (*ProtoNode) ResolveLink ¶ added in v0.4.5
func (*ProtoNode) Size ¶ added in v0.4.5
Size returns the total size of the data addressed by node, including the total sizes of references.