Documentation ¶
Overview ¶
package merkledag implements the ipfs Merkle DAG datastructures.
Index ¶
- Variables
- func FetchGraph(ctx context.Context, root *Node, serv DAGService) chan struct{}
- type DAGService
- type Link
- type Node
- func (n *Node) AddNodeLink(name string, that *Node) error
- func (n *Node) AddNodeLinkClean(name string, that *Node) error
- func (n *Node) Copy() *Node
- func (n *Node) Encoded(force bool) ([]byte, error)
- func (n *Node) Key() (u.Key, error)
- func (n *Node) Marshal() ([]byte, error)
- func (n *Node) MarshalTo(encoded []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) Unmarshal(encoded []byte) error
- type NodeMap
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = fmt.Errorf("merkledag: not found")
Functions ¶
func FetchGraph ¶
func FetchGraph(ctx context.Context, root *Node, serv DAGService) chan struct{}
FetchGraph asynchronously fetches all nodes that are children of the given node, and returns a channel that may be waited upon for the fetch to complete
Types ¶
type DAGService ¶
type DAGService interface { Add(*Node) (u.Key, error) AddRecursive(*Node) error Get(u.Key) (*Node, error) Remove(*Node) error }
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 ¶
AddNodeLink adds a link to another node. without keeping a reference to the child 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) Marshal ¶
Marshal encodes a *Node instance into a new byte slice. The conversion uses an intermediate PBNode.
func (*Node) MarshalTo ¶
MarshalTo encodes a *Node instance into a given byte slice. The conversion uses an intermediate PBNode.
func (*Node) RemoveNodeLink ¶
Remove a link on this node by the given name