merkle-trie / net.consensys.cava.trie.experimental / MerklePatriciaTrie

MerklePatriciaTrie

class MerklePatriciaTrie<V> : MerkleTrie<Bytes, V> (source)

An in-memory MerkleTrie.

Parameters

valueSerializer - A function for serializing values to bytes.

Parameters

Constructors

<init>

MerklePatriciaTrie(valueSerializer: Function<V, Bytes>)
MerklePatriciaTrie(valueSerializer: (V) -> Bytes)

Creates an empty trie.

Functions

get

suspend fun get(key: Bytes): V?

Returns the value that corresponds to the specified key, or an empty byte array if no such value exists.

put

suspend fun put(key: Bytes, value: V?): Unit

Updates the value that corresponds to the specified key, creating the value if one does not already exist.

remove

suspend fun remove(key: Bytes): Unit

Deletes the value that corresponds to the specified key, if such a value exists.

rootHash

fun rootHash(): Bytes32

Returns the KECCAK256 hash of the root node of the trie.

toString

fun toString(): String

Inherited Functions

getAsync

open fun getAsync(key: K): AsyncResult<Optional<V>>

Returns the value that corresponds to the specified key, or an empty byte array if no such value exists.

putAsync

open fun putAsync(key: K, value: V?): AsyncCompletion

Updates the value that corresponds to the specified key, creating the value if one does not already exist.

removeAsync

open fun removeAsync(key: K): AsyncCompletion

Deletes the value that corresponds to the specified key, if such a value exists.

Companion Object Functions

storingBytes

fun storingBytes(): MerklePatriciaTrie<Bytes>

Create a trie with keys and values of type Bytes.

storingStrings

fun storingStrings(): MerklePatriciaTrie<String>

Create a trie with value of type String.