Documentation ¶
Index ¶
- Constants
- func ApplyChange(ctx context.Context, ds ipld.DAGService, nd *dag.ProtoNode, cs []*Change) (*dag.ProtoNode, error)
- func DiffEnumerate(ctx context.Context, dserv ipld.NodeGetter, from, to cid.Cid) error
- func MergeDiffs(a, b []*Change) ([]*Change, []Conflict)
- func NewMemoryDagService() ipld.DAGService
- type Change
- type Conflict
- type Editor
- func (e *Editor) Finalize(ctx context.Context, ds ipld.DAGService) (*dag.ProtoNode, error)
- func (e *Editor) GetDagService() ipld.DAGService
- func (e *Editor) GetNode() *dag.ProtoNode
- func (e *Editor) InsertNodeAtPath(ctx context.Context, pth string, toinsert ipld.Node, ...) error
- func (e *Editor) RmLink(ctx context.Context, pth string) error
Constants ¶
const ( Add = iota Remove Mod )
These constants define the changes that can be applied to a DAG.
Variables ¶
This section is empty.
Functions ¶
func ApplyChange ¶
func ApplyChange(ctx context.Context, ds ipld.DAGService, nd *dag.ProtoNode, cs []*Change) (*dag.ProtoNode, error)
ApplyChange applies the requested changes to the given node in the given dag.
func DiffEnumerate ¶
DiffEnumerate fetches every object in the graph pointed to by 'to' that is not in 'from'. This can be used to more efficiently fetch a graph if you can guarantee you already have the entirety of 'from'
func MergeDiffs ¶
MergeDiffs takes two slice of changes and adds them to a single slice. When a Change from b happens to the same path of an existing change in a, a conflict is created and b is not added to the merged slice. A slice of Conflicts is returned and contains pointers to the Changes involved (which share the same path).
func NewMemoryDagService ¶
func NewMemoryDagService() ipld.DAGService
NewMemoryDagService returns a new, thread-safe in-memory DAGService.
Types ¶
type Change ¶
type Change struct { Type coreiface.ChangeType Path string Before cid.Cid After cid.Cid }
Change represents a change to a DAG and contains a reference to the old and new CIDs.
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor represents a ProtoNode tree editor and provides methods to modify it.
func NewDagEditor ¶
func NewDagEditor(root *dag.ProtoNode, source ipld.DAGService) *Editor
NewDagEditor returns an ProtoNode editor.
* root is the node to be modified * source is the dagstore to pull nodes from (optional)
func (*Editor) Finalize ¶
Finalize writes the new DAG to the given DAGService and returns the modified root node.
func (*Editor) GetDagService ¶
func (e *Editor) GetDagService() ipld.DAGService
GetDagService returns the DAGService used by this editor.