Documentation ¶
Overview ¶
package merkledag implements the ipfs Merkle DAG datastructures.
Index ¶
- Variables
- func EnumerateChildren(ctx context.Context, ds DAGService, root *Node, set key.KeySet) error
- func EnumerateChildrenAsync(ctx context.Context, ds DAGService, root *Node, set key.KeySet) error
- func FetchGraph(ctx context.Context, root *Node, serv DAGService) error
- func FindLinks(links []key.Key, k key.Key, start int) []int
- type Batch
- type DAGService
- type Link
- type LinkSlice
- type Node
- func (n *Node) AddNodeLink(name string, that *Node) error
- func (n *Node) AddNodeLinkClean(name string, that *Node) error
- func (n *Node) AddRawLink(name string, l *Link) error
- func (n *Node) Copy() *Node
- func (n *Node) Encoded(force bool) ([]byte, error)
- func (n *Node) GetLinkedNode(ctx context.Context, ds DAGService, name string) (*Node, error)
- func (n *Node) GetNodeLink(name string) (*Link, error)
- func (n *Node) Key() (key.Key, error)
- func (n *Node) Marshal() ([]byte, error)
- func (n *Node) Multihash() (mh.Multihash, error)
- func (n *Node) RemoveNodeLink(name string) error
- func (n *Node) Size() (uint64, error)
- func (n *Node) Stat() (*NodeStat, error)
- func (n *Node) Unmarshal(encoded []byte) error
- func (n *Node) UpdateNodeLink(name string, that *Node) (*Node, error)
- type NodeGetter
- type NodeStat
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = fmt.Errorf("merkledag: not found")
Functions ¶
func EnumerateChildren ¶
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 ¶
func FetchGraph ¶
func FetchGraph(ctx context.Context, root *Node, serv DAGService) error
FetchGraph fetches all nodes that are children of the given node
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) (key.Key, error) AddRecursive(*Node) error Get(context.Context, key.Key) (*Node, error) Remove(*Node) error // GetDAG returns, in order, all the single leve child // nodes of the passed in node. GetDAG(context.Context, *Node) []NodeGetter GetNodes(context.Context, []key.Key) []NodeGetter Batch() *Batch }
DAGService is an IPFS Merkle DAG service.
func NewDAGService ¶
func NewDAGService(bs *bserv.BlockService) DAGService
type Link ¶
type Link struct { // utf string name. should be unique per object Name string // utf8 // cumulative size of target object Size uint64 // multihash of the target object Hash mh.Multihash // a ptr to the actual node for graph manipulation Node *Node }
Link represents an IPFS Merkle DAG Link between Nodes.
type Node ¶
Node represents a node in the IPFS Merkle DAG. nodes have opaque data and a set of navigable links.
func (*Node) AddNodeLink ¶
AddNodeLink adds a link to another node.
func (*Node) AddNodeLinkClean ¶
AddNodeLinkClean adds a link to another node. without keeping a reference to the child node
func (*Node) AddRawLink ¶ added in v0.3.2
AddRawLink adds a copy of a link to this node
func (*Node) Copy ¶
Copy returns a copy of the node. NOTE: does not make copies of Node objects in the links.
func (*Node) Encoded ¶
Encoded returns the encoded raw data version of a Node instance. It may use a cached encoded version, unless the force flag is given.
func (*Node) GetLinkedNode ¶ added in v0.3.6
func (*Node) GetNodeLink ¶ added in v0.3.2
Return a copy of the link with given name
func (*Node) Marshal ¶
Marshal encodes a *Node instance into a new byte slice. The conversion uses an intermediate PBNode.
func (*Node) RemoveNodeLink ¶
Remove a link on this node by the given name
func (*Node) Size ¶
Size returns the total size of the data addressed by node, including the total sizes of references.
type NodeGetter ¶
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.
type NodeStat ¶
type NodeStat struct { Hash string NumLinks int // number of links in link table BlockSize int // size of the raw, encoded data LinksSize int // size of the links segment DataSize int // size of the data segment CumulativeSize int // cumulative size of object and its references }
NodeStat is a statistics object for a Node. Mostly sizes.