trienode

package
v1.14.6-0...-341647f Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: GPL-3.0 Imports: 10 Imported by: 141

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 node 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) Flatten added in v1.12.1

func (set *MergedNodeSet) Flatten() map[common.Hash]map[string]*Node

Flatten returns a two-dimensional map for internal nodes.

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 Node

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

Node is a wrapper which contains the encoded blob of the trie node and its node hash. It is general enough that can be used to represent trie node corresponding to different trie implementations.

func New

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

New constructs a node with provided node information.

func NewDeleted added in v1.12.1

func NewDeleted() *Node

NewDeleted constructs a node which is deleted.

func (*Node) IsDeleted

func (n *Node) IsDeleted() bool

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

func (*Node) Size

func (n *Node) Size() int

Size returns the total memory size used by this node.

type NodeSet

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

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

func NewNodeSet

func NewNodeSet(owner common.Hash) *NodeSet

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

func (*NodeSet) AddLeaf

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

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

func (*NodeSet) AddNode

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

AddNode adds the provided node into set.

func (*NodeSet) ForEachWithOrder

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

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) HashSet added in v1.14.12

func (set *NodeSet) HashSet() map[common.Hash][]byte

HashSet returns a set of trie nodes keyed by node hash.

func (*NodeSet) Merge added in v1.12.1

func (set *NodeSet) Merge(owner common.Hash, nodes map[string]*Node) error

Merge adds a set of nodes into the set.

func (*NodeSet) MergeSet added in v1.14.12

func (set *NodeSet) MergeSet(other *NodeSet) error

MergeSet merges this 'set' with 'other'. It assumes that the sets are disjoint, and thus does not deduplicate data (count deletes, dedup leaves etc).

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 ProofList added in v1.13.3

type ProofList []rlp.RawValue

ProofList stores an ordered list of trie nodes. It implements ethdb.KeyValueWriter.

func (ProofList) DataSize added in v1.13.3

func (n ProofList) DataSize() int

DataSize returns the aggregated data size of nodes in the list

func (*ProofList) Delete added in v1.13.3

func (n *ProofList) Delete(key []byte) error

Delete panics as there's no reason to remove a node from the list.

func (*ProofList) Put added in v1.13.3

func (n *ProofList) Put(key []byte, value []byte) error

Put stores a new node at the end of the list

func (ProofList) Set added in v1.13.3

func (n ProofList) Set() *ProofSet

Set converts the node list to a ProofSet

func (ProofList) Store added in v1.13.3

func (n ProofList) Store(db ethdb.KeyValueWriter)

Store writes the contents of the list to the given database

type ProofSet added in v1.13.3

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

ProofSet stores a set of trie nodes. It implements trie.Database and can also act as a cache for another trie.Database.

func NewProofSet added in v1.13.3

func NewProofSet() *ProofSet

NewProofSet creates an empty node set

func (*ProofSet) DataSize added in v1.13.3

func (db *ProofSet) DataSize() int

DataSize returns the aggregated data size of nodes in the set

func (*ProofSet) Delete added in v1.13.3

func (db *ProofSet) Delete(key []byte) error

Delete removes a node from the set

func (*ProofSet) DeleteRange added in v1.14.12

func (db *ProofSet) DeleteRange(start, end []byte) error

func (*ProofSet) Get added in v1.13.3

func (db *ProofSet) Get(key []byte) ([]byte, error)

Get returns a stored node

func (*ProofSet) Has added in v1.13.3

func (db *ProofSet) Has(key []byte) (bool, error)

Has returns true if the node set contains the given key

func (*ProofSet) KeyCount added in v1.13.3

func (db *ProofSet) KeyCount() int

KeyCount returns the number of nodes in the set

func (*ProofSet) List added in v1.13.3

func (db *ProofSet) List() [][]byte

List converts the node set to a slice of bytes.

func (*ProofSet) Put added in v1.13.3

func (db *ProofSet) Put(key []byte, value []byte) error

Put stores a new node in the set

func (*ProofSet) Store added in v1.13.3

func (db *ProofSet) Store(target ethdb.KeyValueWriter)

Store writes the contents of the set to the given database

Jump to

Keyboard shortcuts

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