tuweni / org.apache.tuweni.trie / 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>

Creates an empty trie.

MerklePatriciaTrie(valueSerializer: (V) -> Bytes)

Functions

get

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

suspend fun get(key: Bytes): V?

getAsync

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

fun getAsync(key: Bytes): AsyncResult<V?>

put

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

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

putAsync

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

fun putAsync(key: Bytes, value: V?): AsyncCompletion

remove

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

suspend fun remove(key: Bytes): Unit

removeAsync

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

fun removeAsync(key: Bytes): AsyncCompletion

rootHash

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

fun rootHash(): Bytes32

toString

fun toString(): String

Companion Object Functions

create

Create a trie.

fun <V> create(valueSerializer: Function<V, Bytes>): MerklePatriciaTrie<V>

storingBytes

Create a trie with keys and values of type Bytes.

fun storingBytes(): MerklePatriciaTrie<Bytes>

storingStrings

Create a trie with value of type String.

fun storingStrings(): MerklePatriciaTrie<String>