Module io.hotmoka.patricia
Package io.hotmoka.patricia
Interface PatriciaTrie<Key,Value extends Marshallable>
-
public interface PatriciaTrie<Key,Value extends Marshallable>A Merkle-Patricia trie.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<Value>get(Key key)Yields the value bound to the given key.byte[]getRoot()Yields the root of the trie, that can be used as a hash of its content.static <Key,Value extends Marshallable>
PatriciaTrie<Key,Value>of(KeyValueStore store, HashingAlgorithm<? super Key> hashingForKeys, HashingAlgorithm<? super Node> hashingForNodes, Marshallable.Unmarshaller<? extends Value> valueUnmarshaller, boolean garbageCollected)Yields the Merkle-Patricia trie supported by the underlying store, using the given hashing algorithm to hash nodes, keys and the values.voidput(Key key, Value value)Binds the given key to the given value.
-
-
-
Method Detail
-
get
Optional<Value> get(Key key)
Yields the value bound to the given key.- Parameters:
key- the key- Returns:
- the value, if any
-
put
void put(Key key, Value value)
Binds the given key to the given value. It replaces it if already present.- Parameters:
key- the keyvalue- the value
-
getRoot
byte[] getRoot()
Yields the root of the trie, that can be used as a hash of its content.- Returns:
- the root
-
of
static <Key,Value extends Marshallable> PatriciaTrie<Key,Value> of(KeyValueStore store, HashingAlgorithm<? super Key> hashingForKeys, HashingAlgorithm<? super Node> hashingForNodes, Marshallable.Unmarshaller<? extends Value> valueUnmarshaller, boolean garbageCollected)
Yields the Merkle-Patricia trie supported by the underlying store, using the given hashing algorithm to hash nodes, keys and the values.- Parameters:
store- the store used to store a mapping from nodes' hashes to their contenthashingForKeys- the hashing algorithm for the keyshashingForNodes- the hashing algorithm for the nodes of the trievalueUnmarshaller- a function able to unmarshall a value from its byte representationgarbageCollected- true if and only if unused nodes must be garbage collected; in general, this can be true if previous configurations of the trie needn't be rechecked out in the future- Returns:
- the trie
-
-