Interface PatriciaTrie<Key,​Value extends Marshallable>


  • public interface PatriciaTrie<Key,​Value extends Marshallable>
    A Merkle-Patricia trie.
    • 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 key
        value - 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 MarshallablePatriciaTrie<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 content
        hashingForKeys - the hashing algorithm for the keys
        hashingForNodes - the hashing algorithm for the nodes of the trie
        valueUnmarshaller - a function able to unmarshall a value from its byte representation
        garbageCollected - 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