tuweni / org.apache.tuweni.trie / StoredMerklePatriciaTrie

StoredMerklePatriciaTrie

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

A MerkleTrie that persists trie nodes to a MerkleStorage key/value store.

Parameters

Constructors

<init>

StoredMerklePatriciaTrie(storage: MerkleStorage, valueSerializer: (V) -> Bytes, valueDeserializer: (Bytes) -> V)
StoredMerklePatriciaTrie(storage: MerkleStorage, rootHash: Bytes32, valueSerializer: (V) -> Bytes, valueDeserializer: (Bytes) -> V)

Create a trie.

Functions

clearCache

fun clearCache(): Unit

Forces any cached trie nodes to be released, so they can be garbage collected.

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<V?>
open fun getAsync(dispatcher: CoroutineDispatcher, key: K): AsyncResult<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
open fun putAsync(dispatcher: CoroutineDispatcher, 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
open fun removeAsync(dispatcher: CoroutineDispatcher, key: K): AsyncCompletion

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

Companion Object Functions

create

fun <V> create(storage: MerkleStorage, valueSerializer: Function<V, Bytes>, valueDeserializer: Function<Bytes, V>): StoredMerklePatriciaTrie<V>
fun <V> create(storage: MerkleStorage, rootHash: Bytes32, valueSerializer: Function<V, Bytes>, valueDeserializer: Function<Bytes, V>): StoredMerklePatriciaTrie<V>

Create a trie.

storingBytes

fun storingBytes(storage: MerkleStorage): StoredMerklePatriciaTrie<Bytes>

Create a trie with value of type Bytes.

fun storingBytes(storage: MerkleStorage, rootHash: Bytes32): StoredMerklePatriciaTrie<Bytes>

Create a trie with keys and values of type Bytes.

storingStrings

fun storingStrings(storage: MerkleStorage): StoredMerklePatriciaTrie<String>

Create a trie with value of type String.

fun storingStrings(storage: MerkleStorage, rootHash: Bytes32): StoredMerklePatriciaTrie<String>

Create a trie with keys and values of type String.