ads

package module
v0.0.0-...-113b215 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0, BSD-2-Clause Imports: 9 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map[IdentifierType types.IdentifierType, K, V any] interface {
	// Set sets the given key to the given value.
	Set(key K, value V) error

	// Get returns the value for the given key.
	Get(key K) (value V, exists bool, err error)

	// Has returns true if the given key exists.
	Has(key K) (exists bool, err error)

	// Delete deletes the given key.
	Delete(key K) (deleted bool, err error)

	// Stream streams all key-value pairs to the given consumer function.
	Stream(consumerFunc func(key K, value V) error) error

	// Commit persists the changes to the underlying store.
	Commit() error

	// Root returns the root of the sparse merkle tree.
	Root() IdentifierType

	// Size returns the number of elements in the map.
	Size() int

	// WasRestoredFromStorage returns true if the map was restored from an existing storage.
	WasRestoredFromStorage() bool
}

Map is a map that can produce proofs for its values which can be verified against a known merkle root that is formed using a sparse merkle tree.

func NewMap

func NewMap[IdentifierType types.IdentifierType, K, V any](
	store kvstore.KVStore,
	identifierToBytes kvstore.ObjectToBytes[IdentifierType],
	bytesToIdentifier kvstore.BytesToObject[IdentifierType],
	keyToBytes kvstore.ObjectToBytes[K],
	bytesToKey kvstore.BytesToObject[K],
	valueToBytes kvstore.ObjectToBytes[V],
	bytesToValue kvstore.BytesToObject[V],
) Map[IdentifierType, K, V]

NewMap creates a new AuthenticatedMap.

type Set

type Set[IdentifierType types.IdentifierType, K any] interface {
	// Root returns the root of the sparse merkle tree.
	Root() IdentifierType

	// Add adds the key to the set.
	Add(key K) error

	// Has returns true if the given key exists.
	Has(key K) (exists bool, err error)

	// Delete deletes the given key.
	Delete(key K) (deleted bool, err error)

	// Stream streams all the set elements to the given consumer function.
	Stream(consumerFunc func(key K) error) error

	// Commit persists the changes to the underlying store.
	Commit() error

	// Size returns the number of elements in the set.
	Size() int

	// WasRestoredFromStorage returns true if the set was restored from an existing storage.
	WasRestoredFromStorage() bool
}

Set is a set that can produce proofs for its elements which can be verified against a known merkle root that is formed using a sparse merkle tree.

func NewSet

func NewSet[IdentifierType types.IdentifierType, K any](
	store kvstore.KVStore,
	identifierToBytes kvstore.ObjectToBytes[IdentifierType],
	bytesToIdentifier kvstore.BytesToObject[IdentifierType],
	keyToBytes kvstore.ObjectToBytes[K],
	bytesToKey kvstore.BytesToObject[K],
) Set[IdentifierType, K]

NewSet creates a new sparse merkle tree based set.

Jump to

Keyboard shortcuts

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