Documentation ¶
Overview ¶
package merkledag implements the IPFS Merkle DAG datastructures.
Index ¶
- Variables
- func EnumerateChildren(ctx context.Context, ds LinkService, root *cid.Cid, visit func(*cid.Cid) bool, ...) error
- func EnumerateChildrenAsync(ctx context.Context, ds DAGService, c *cid.Cid, visit func(*cid.Cid) bool) error
- func FetchGraph(ctx context.Context, c *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 LinkService
- type LinkSlice
- type NodeGetter
- type NodeOption
- 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) Key() key.Key
- func (n *ProtoNode) Links() []*node.Link
- func (n *ProtoNode) Loggable() map[string]interface{}
- func (n *ProtoNode) Marshal() ([]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) 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")
Functions ¶
func EnumerateChildren ¶ added in v0.4.0
func EnumerateChildren(ctx context.Context, ds LinkService, root *cid.Cid, visit func(*cid.Cid) bool, bestEffort 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 Batch ¶ added in v0.3.6
type Batch struct { MaxSize int // contains filtered or unexported fields }
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 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 ProtoNode ¶
type ProtoNode struct {
// 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 ¶
AddNodeLink adds a link to another node.
func (*ProtoNode) AddNodeLinkClean ¶
AddNodeLinkClean adds a link to another node. without keeping a reference to the child node
func (*ProtoNode) AddRawLink ¶
AddRawLink adds a copy of a link to this node
func (*ProtoNode) Copy ¶
Copy returns a copy of the node. NOTE: Does not make copies of Node objects in the links.
func (*ProtoNode) EncodeProtobuf ¶
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 ¶
func (*ProtoNode) GetLinkedProtoNode ¶
func (*ProtoNode) GetNodeLink ¶
Return a copy of the link with given name
func (*ProtoNode) Marshal ¶
Marshal encodes a *Node instance into a new byte slice. The conversion uses an intermediate PBNode.
func (*ProtoNode) RemoveNodeLink ¶
Remove a link on this node by the given name
func (*ProtoNode) ResolveLink ¶
func (*ProtoNode) Size ¶
Size returns the total size of the data addressed by node, including the total sizes of references.