dag

package
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dag

type Dag struct {
	Tip   cid.Cid
	Store nodestore.DagStore
}

Dag is a convenience wrapper around a node store for setting and pruning

func NewDag

func NewDag(_ context.Context, tip cid.Cid, store nodestore.DagStore) *Dag

NewDag takes a tip and a store and returns an initialized Dag

func NewDagWithNodes

func NewDagWithNodes(ctx context.Context, store nodestore.DagStore, nodes ...format.Node) (*Dag, error)

NewDagWithNodes creates a new Dag, and imports the passed in nodes, the first node is set as the tip

func (*Dag) AddNodes

func (d *Dag) AddNodes(ctx context.Context, nodes ...format.Node) error

AddNodes takes cbornodes and adds them to the underlying storage

func (*Dag) CreateNode

func (d *Dag) CreateNode(ctx context.Context, obj interface{}) (format.Node, error)

CreateNode adds an object to the Dags underlying storage (doesn't change the tip) and returns the cbornode

func (*Dag) Delete

func (d *Dag) Delete(ctx context.Context, path []string) (*Dag, error)

Delete removes a key from the dag

func (*Dag) Dump

func (d *Dag) Dump(ctx context.Context) string

Dump dumps the current DAG out as a string for debugging

func (*Dag) Get

func (d *Dag) Get(ctx context.Context, id cid.Cid) (format.Node, error)

Get takes a CID and returns the cbornode

func (*Dag) Nodes

func (d *Dag) Nodes(ctx context.Context) ([]format.Node, error)

Nodes returns all the nodes in an entire tree from the Tip out

func (*Dag) NodesForPath

func (d *Dag) NodesForPath(ctx context.Context, path []string) ([]format.Node, error)

func (*Dag) NodesForPathWithDecendants

func (d *Dag) NodesForPathWithDecendants(ctx context.Context, path []string) ([]format.Node, error)

func (*Dag) Resolve

func (d *Dag) Resolve(ctx context.Context, path []string) (interface{}, []string, error)

Resolve takes a path (as a string slice) and returns the value, remaining path and any error.

func (*Dag) ResolveAt

func (d *Dag) ResolveAt(ctx context.Context, tip cid.Cid, path []string) (val interface{}, remaining []string, err error)

ResolveAt takes a tip and a path (as a string slice) and returns the value, remaining path and any error.

func (*Dag) ResolveInto

func (d *Dag) ResolveInto(ctx context.Context, path []string, obj interface{}) error

func (*Dag) Set

func (d *Dag) Set(ctx context.Context, pathAndKey []string, val interface{}) (*Dag, error)

Set sets a value at a path and returns a new dag with a new tip that reflects the new state

func (d *Dag) SetAsLink(ctx context.Context, pathAndKey []string, val interface{}) (*Dag, error)

SetAsLink sets a value at a path and returns a new dag with a new tip that reflects the new state

func (*Dag) Update

func (d *Dag) Update(ctx context.Context, path []string, newObj interface{}) (*Dag, error)

Update returns a new Dag with the old node at path swapped out for the new object

func (*Dag) WithNewTip

func (d *Dag) WithNewTip(tip cid.Cid) *Dag

WithNewTip returns a new Dag, but with the Tip set to the argument

type NodeMap

type NodeMap map[cid.Cid]format.Node

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL