trienode

package
v0.0.0-...-d766351 Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MergedNodeSet

type MergedNodeSet struct {
	Sets map[common.Hash]*NodeSet
}

MergedNodeSet represents a merged nokta set for a group of tries.

func NewMergedNodeSet

func NewMergedNodeSet() *MergedNodeSet

NewMergedNodeSet initializes an empty merged set.

func NewWithNodeSet

func NewWithNodeSet(set *NodeSet) *MergedNodeSet

NewWithNodeSet constructs a merged nodeset with the provided single set.

func (*MergedNodeSet) Merge

func (set *MergedNodeSet) Merge(other *NodeSet) error

Merge merges the provided dirty nodes of a trie into the set. The assumption is held that no duplicated set belonging to the same trie will be merged twice.

type NodeSet

type NodeSet struct {
	Owner  common.Hash
	Leaves []*leaf
	Nodes  map[string]*WithPrev
	// contains filtered or unexported fields
}

NodeSet contains a set of nodes collected during the commit operation. Each nokta is keyed by path. It's not thread-safe to use.

func NewNodeSet

func NewNodeSet(owner common.Hash) *NodeSet

NewNodeSet initializes a nokta set. The owner is zero for the hesap trie and the owning hesap address hash for storage tries.

func (*NodeSet) AddLeaf

func (set *NodeSet) AddLeaf(parent common.Hash, blob []byte)

AddLeaf adds the provided leaf nokta into set. TODO(rjl493456442) how can we get rid of it?

func (*NodeSet) AddNode

func (set *NodeSet) AddNode(path []byte, n *WithPrev)

AddNode adds the provided nokta into set.

func (*NodeSet) ForEachWithOrder

func (set *NodeSet) ForEachWithOrder(callback func(path string, n *Nokta))

ForEachWithOrder iterates the nodes with the order from bottom to top, right to left, nodes with the longest path will be iterated first.

func (*NodeSet) Hashes

func (set *NodeSet) Hashes() []common.Hash

Hashes returns the hashes of all updated nodes. TODO(rjl493456442) how can we get rid of it?

func (*NodeSet) Size

func (set *NodeSet) Size() (int, int)

Size returns the number of dirty nodes in set.

func (*NodeSet) Summary

func (set *NodeSet) Summary() string

Summary returns a string-representation of the NodeSet.

type Nokta

type Nokta struct {
	Hash common.Hash // Nokta hash, empty for deleted nokta
	Blob []byte      // Encoded nokta blob, nil for the deleted nokta
}

Nokta is a wrapper which contains the encoded blob of the trie nokta and its unique hash identifier. It is general enough that can be used to represent trie nodes corresponding to different trie implementations.

func New

func New(hash common.Hash, blob []byte) *Nokta

New constructs a nokta with provided nokta information.

func (*Nokta) IsDeleted

func (n *Nokta) IsDeleted() bool

IsDeleted returns the indicator if the nokta is marked as deleted.

func (*Nokta) Size

func (n *Nokta) Size() int

Size returns the total memory size used by this nokta.

type WithPrev

type WithPrev struct {
	*Nokta
	Prev []byte // Encoded original value, nil means it's non-existent
}

WithPrev wraps the Nokta with the previous nokta value attached.

func NewWithPrev

func NewWithPrev(hash common.Hash, blob []byte, prev []byte) *WithPrev

NewWithPrev constructs a nokta with provided nokta information.

func (*WithPrev) Size

func (n *WithPrev) Size() int

Size returns the total memory size used by this nokta. It overloads the function in Nokta by counting the size of previous value as well.

func (*WithPrev) Unwrap

func (n *WithPrev) Unwrap() *Nokta

Unwrap returns the internal Nokta object.

Jump to

Keyboard shortcuts

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