ptrie

package
v0.37.0-crescendo-RC9-... Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrMissingPath added in v0.10.0

type ErrMissingPath struct {
	Paths []ledger.Path
}

func (ErrMissingPath) Error added in v0.10.0

func (e ErrMissingPath) Error() string

type PSMT

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

PSMT (Partial Sparse Merkle Tree) holds a subset of an sparse merkle tree at specific state (no historic views). Instead of keeping any unneeded branch, it only keeps the hash of subtree. This implementation is fully stored in memory and doesn't use a database.

DEFINITIONS and CONVENTIONS:

  • HEIGHT of a node v in a tree is the number of edges on the longest downward path between v and a tree leaf. The height of a tree is the heights of its root. The height of a Trie is always the height of the fully-expanded tree.

func NewPSMT

func NewPSMT(
	rootValue ledger.RootHash,
	batchProof *ledger.TrieBatchProof,
) (*PSMT, error)

NewPSMT builds a Partial Sparse Merkle Tree (PSMT) given a chunkdatapack registertouches TODO just accept batch proof as input

func (*PSMT) Get

func (p *PSMT) Get(paths []ledger.Path) ([]*ledger.Payload, error)

Get returns an slice of payloads (same order), an slice of failed paths and errors (if any) TODO return list of indecies instead of paths

func (*PSMT) GetSinglePayload added in v0.26.2

func (p *PSMT) GetSinglePayload(path ledger.Path) (*ledger.Payload, error)

GetSinglePayload returns payload of a given path

func (*PSMT) RootHash

func (p *PSMT) RootHash() ledger.RootHash

RootHash returns the rootNode hash value of the SMT

func (*PSMT) Update

func (p *PSMT) Update(paths []ledger.Path, payloads []*ledger.Payload) (ledger.RootHash, error)

Update updates registers and returns rootValue after updates in case of error, it returns a list of paths for which update failed

type Root

type Root hash.Hash

Root hash of a node

func (Root) String

func (r Root) String() string

Jump to

Keyboard shortcuts

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