Module io.hotmoka.patricia.api
Package io.hotmoka.patricia.api
Interface PatriciaTrie<Key,Value,T extends PatriciaTrie<Key,Value,T>>
- Type Parameters:
Key- the type of the keys of the trieValue- the type of the values of the trieT- the type of this trie
public interface PatriciaTrie<Key,Value,T extends PatriciaTrie<Key,Value,T>>
A Merkle-Patricia trie.
-
Method Summary
Modifier and TypeMethodDescriptioncheckoutAt(byte[] root) Yields an independent clone of this trie, but for its root, that is set to the provided value.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.Binds the given key to the given value.
-
Method Details
-
get
Yields the value bound to the given key.- Parameters:
key- the key- Returns:
- the value, if any
- Throws:
TrieException- if this Patricia trie is not able to complete the operation correctly
-
put
Binds the given key to the given value. It replaces it if it was already present. This trie is not modified, but a new trie is returned instead, identical to this but for the added binding.- Parameters:
key- the keyvalue- the value- Returns:
- the resulting, modified Patricia trie
- Throws:
TrieException- if this Patricia trie is not able to complete the operation correctly
-
getRoot
Yields the root of the trie, that can be used as a hash of its content.- Returns:
- the root
- Throws:
TrieException- if this Patricia trie is not able to complete the operation correctly
-
checkoutAt
Yields an independent clone of this trie, but for its root, that is set to the provided value.- Parameters:
root- the root to use in the cloned trie- Returns:
- the resulting, cloned trie
- Throws:
TrieException- if this Patricia trie is not able to complete the operation correctly
-