Documentation
¶
Index ¶
- Variables
- type Entry
- type Index
- type Iterator
- type Machine
- func (mach *Machine) BatchEdit(ctx context.Context, s schema.RW, root Root, opsSeq iter.Seq[Op]) (*Root, error)
- func (mach *Machine) Delete(ctx context.Context, s bcsdk.RWD, root Root, key []byte) (*Root, error)
- func (o *Machine) Get(ctx context.Context, s schema.RO, root Root, key []byte, dst *[]byte) (bool, error)
- func (mach *Machine) MinEntry(ctx context.Context, s schema.RO, root Root, gteq []byte) (*Entry, error)
- func (o *Machine) NewEmpty(ctx context.Context, s schema.RW) (*Root, error)
- func (mach *Machine) NewIterator(s schema.RO, root Root, span Span) *Iterator
- func (mach *Machine) NewTx(s bcsdk.RWD, prevRoot Root) *Tx
- func (mach *Machine) NewTxOnEmpty(s bcsdk.RWD) *Tx
- func (o *Machine) Populate(ctx context.Context, s schema.RO, root Root, set cadata.Set, ...) error
- func (o *Machine) PostSlice(ctx context.Context, s schema.RW, ents []Entry) (*Root, error)
- func (mach *Machine) Put(ctx context.Context, s schema.RW, root Root, key, value []byte) (*Root, error)
- func (o *Machine) Sync(ctx context.Context, dst schema.WO, src schema.RO, root Root, ...) error
- func (o *Machine) Validate(ctx context.Context, s schema.RO, x Root) error
- func (mach *Machine) Walk(ctx context.Context, s schema.RO, root Root, w Walker) error
- type Op
- type Ref
- type Root
- type Span
- type Tx
- type VNodeEntry
- type Walker
Constants ¶
This section is empty.
Variables ¶
var ( ErrCannotCollapse = errors.Errorf("cannot collapse parent into child") ErrCannotSplit = errors.Errorf("cannot split, < 2 entries") )
Functions ¶
This section is empty.
Types ¶
type Entry ¶
Entry represents a key-value pair in the trie. See-also: IndexEntry for entries that refer to other nodes. and VNodeEntry for entries that contain other nodes inline.
type Index ¶
type Index struct {
// Prefix is the common prefix of all the entries in the referenced node.
Prefix []byte
// Ref is the reference to the node.
Ref Ref
// Count is the cumulative number of entries transitively reachable from this node.
Count uint64
}
Index represents metadata about a trie node reference
type Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine holds caches and configuration for operating on tries.
func (*Machine) BatchEdit ¶
func (mach *Machine) BatchEdit(ctx context.Context, s schema.RW, root Root, opsSeq iter.Seq[Op]) (*Root, error)
BatchEdit applies a batch of operations to a root, returning a new root. All ops produced by opsSeq will be collected and sorted.
func (*Machine) Get ¶
func (o *Machine) Get(ctx context.Context, s schema.RO, root Root, key []byte, dst *[]byte) (bool, error)
Get retrieves a value at key if it exists, otherwise ErrNotFound is returned
func (*Machine) MinEntry ¶
func (mach *Machine) MinEntry(ctx context.Context, s schema.RO, root Root, gteq []byte) (*Entry, error)
MinEntry returns the first entry >= gteq
func (*Machine) NewIterator ¶
func (*Machine) NewTxOnEmpty ¶
NewTxOnEmpty creates a new Tx based on an empty Trie.
func (*Machine) Put ¶
func (mach *Machine) Put(ctx context.Context, s schema.RW, root Root, key, value []byte) (*Root, error)
Put returns a copy of root where key maps to value, and all other mappings are unchanged.
func (*Machine) Sync ¶
func (o *Machine) Sync(ctx context.Context, dst schema.WO, src schema.RO, root Root, fn func(Entry) error) error
Sync ensures that data structure exists in dst, using src to retrieve missing pieces. Sync is only correct if dangling references can be guarenteed to not exist in dst.
func (*Machine) Walk ¶
Walk walks a Trie calling methods on Walker throughout the traversal. w.ShouldWalk is called before walking a node, if false is returned the node is skipped w.EntryFn is called for every entry in a node w.NodeFn is called for the node after all the entries reachable from it have been walked.
type Op ¶
Op is a single operation on the trie.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is a transaction on a trie data structure. Tx buffers operations, and presents a logical view of the trie. Tx is not thread-safe.
func (*Tx) Flush ¶
Flush applies the edits to the previous root, and returns the new root. The transaction can continue, after this.
type VNodeEntry ¶ added in v0.0.2
type Walker ¶
type Walker struct {
// ShouldWalk is called immediately before traversing a node.
// ShouldWalk must be set; always return true to naively walk everything.
ShouldWalk func(root Root) bool
// EntryFn, if set, is called for every entry.
EntryFn func(Entry) error
// NodeFn, must be set and is called after visiting every node.
NodeFn func(root Root) error
}