trie

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrInvalidValue  = errors.New("invalid value")
	ErrUnexistingKey = errors.New("unexisting key")
)
View Source
var EmptyNode = &leafNode{&felt.Felt{}}

Functions

This section is empty.

Types

type BinaryNode

type BinaryNode struct {
	LeftH  *felt.Felt
	RightH *felt.Felt
	// contains filtered or unexported fields
}

func (*BinaryNode) Bottom

func (n *BinaryNode) Bottom() *felt.Felt

func (*BinaryNode) Hash

func (n *BinaryNode) Hash() *felt.Felt

func (*BinaryNode) Path

func (n *BinaryNode) Path() *collections.BitSet

type EdgeNode

type EdgeNode struct {
	// contains filtered or unexported fields
}

func NewEdgeNode

func NewEdgeNode(path *collections.BitSet, bottom *felt.Felt) *EdgeNode

func (*EdgeNode) Bottom

func (n *EdgeNode) Bottom() *felt.Felt

func (*EdgeNode) Hash

func (n *EdgeNode) Hash() *felt.Felt

func (*EdgeNode) Path

func (n *EdgeNode) Path() *collections.BitSet

type Trie

type Trie interface {
	Root() *felt.Felt
	Get(key *felt.Felt) (*felt.Felt, error)
	Put(key *felt.Felt, value *felt.Felt) error
	Del(key *felt.Felt) error
}

func New

func New(manager TrieManager, root *felt.Felt, height int) Trie

New creates a new trie, pass zero as root hash to initialize an empty trie

type TrieManager

type TrieManager interface {
	GetTrieNode(hash *felt.Felt) (TrieNode, error)
	StoreTrieNode(node TrieNode) error
}

type TrieNode

type TrieNode interface {
	Path() *collections.BitSet
	Bottom() *felt.Felt
	Hash() *felt.Felt
}

Jump to

Keyboard shortcuts

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