fieldtrie

package
v4.0.0-...-ae7b6de Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFieldTrie = errors.New("invalid field trie")
	ErrEmptyFieldTrie   = errors.New("empty field trie")
)

Functions

func ProofFromMerkleLayers

func ProofFromMerkleLayers(layers [][][]byte, startingLeafIndex int) [][]byte

ProofFromMerkleLayers creates a proof starting at the leaf index of the state Merkle layers.

Types

type FieldTrie

type FieldTrie struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

FieldTrie is the representation of the representative trie of the particular field.

func NewFieldTrie

func NewFieldTrie(field types.FieldIndex, fieldInfo types.DataType, elements interface{}, length uint64) (*FieldTrie, error)

NewFieldTrie is the constructor for the field trie data structure. It creates the corresponding trie according to the given parameters. Depending on whether the field is a basic/composite array which is either fixed/variable length, it will appropriately determine the trie.

func (*FieldTrie) CopyTrie

func (f *FieldTrie) CopyTrie() *FieldTrie

CopyTrie copies the references to the elements the trie is built on.

func (*FieldTrie) Empty

func (f *FieldTrie) Empty() bool

Empty checks whether the underlying field trie is empty or not.

func (*FieldTrie) FieldReference

func (f *FieldTrie) FieldReference() *stateutil.Reference

FieldReference returns the underlying field reference object for the trie.

func (*FieldTrie) InsertFieldLayer

func (f *FieldTrie) InsertFieldLayer(layer [][]*[32]byte)

InsertFieldLayer manually inserts a field layer. This method bypasses the normal method of field computation, it is only meant to be used in tests.

func (*FieldTrie) Length

func (f *FieldTrie) Length() uint64

Length return the length of the whole field trie.

func (*FieldTrie) RecomputeTrie

func (f *FieldTrie) RecomputeTrie(indices []uint64, elements interface{}) ([32]byte, error)

RecomputeTrie rebuilds the affected branches in the trie according to the provided changed indices and elements. This recomputes the trie according to the particular field the trie is based on.

func (*FieldTrie) TransferTrie

func (f *FieldTrie) TransferTrie() *FieldTrie

TransferTrie starts the process of transferring all the trie related data to a new trie. This is done if we know that other states which hold references to this trie will unlikely need it for recomputation. This helps us save on a copy. Any caller of this method will need to take care that this isn't called on an empty trie.

func (*FieldTrie) TrieRoot

func (f *FieldTrie) TrieRoot() ([32]byte, error)

TrieRoot returns the corresponding root of the trie.

Jump to

Keyboard shortcuts

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