ptrie

package
v0.10.3-stop-broadcast... Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: AGPL-3.0 Imports: 7 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 []byte,
	pathByteSize int,
	batchProof *ledger.TrieBatchProof,
) (*PSMT, error)

NewPSMT builds a Partial Sparse Merkle Tree (PMST) 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) PathSize

func (p *PSMT) PathSize() int

PathSize returns the expected expected size bytes of path

func (*PSMT) RootHash

func (p *PSMT) RootHash() []byte

RootHash returns the rootNode hash value of the SMT

func (*PSMT) Update

func (p *PSMT) Update(paths []ledger.Path, payloads []*ledger.Payload) ([]byte, 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 []byte

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