Interface Access

  • All Known Implementing Classes:
    AbstractAccess, Fork, Prefixed, RoErasedAccess, Snapshot

    public interface Access
    Provides access to Exonum MerkleDB indexes. An access object corresponds to a certain database state.

    An access can be read-only or read-write. Read-only accesses produce indexes that forbid modifying operations.

    The changes made to read-write accesses are not usually applied immediately to the database state, but are performed separately. For example, Exonum will apply the changes made by all transactions when a block is confirmed.

    Accesses may perform index address resolution: they may modify the passed index address before fetching it from the database. That implies that addresses passed to index factory methods are relative to an access object. The address resolution rules must be documented in interface implementations.

    As each Access object requires some MerkleDB resources to function, they work in a scope that is usually managed by the framework. When an Access is closed, all indexes created with it are destroyed and become inaccessible; and no new indexes can be created.

    All method arguments are non-null by default.


    This Java interface is similar to a combination of Rust Access and AccessExt traits.

    See Also:
    com.exonum.binding.core.storage.indices, StandardSerializers
    • Method Detail

      • getProofList

        <E> ProofListIndexProxy<E> getProofList​(IndexAddress address,
                                                com.exonum.binding.common.serialization.Serializer<E> serializer)
        Creates a new ProofListIndex.
        Type Parameters:
        E - the type of elements in this list
        Parameters:
        address - an index address in the MerkleDB
        serializer - a serializer of list elements
        Throws:
        IllegalStateException - if this access is not valid
        See Also:
        StandardSerializers
      • getList

        <E> ListIndexProxy<E> getList​(IndexAddress address,
                                      com.exonum.binding.common.serialization.Serializer<E> serializer)
        Creates a new ListIndex.
        Type Parameters:
        E - the type of elements in this list
        Parameters:
        address - an index address in the MerkleDB
        serializer - a serializer of list elements
        Throws:
        IllegalStateException - if this access is not valid
        See Also:
        getProofList(IndexAddress, Serializer), StandardSerializers
      • getProofMap

        <K,​V> ProofMapIndexProxy<K,​V> getProofMap​(IndexAddress address,
                                                              com.exonum.binding.common.serialization.Serializer<K> keySerializer,
                                                              com.exonum.binding.common.serialization.Serializer<V> valueSerializer)
        Creates a new ProofMapIndex.
        Type Parameters:
        K - the type of keys in the map
        V - the type of values in the map
        Parameters:
        address - an index address in the MerkleDB
        keySerializer - a serializer of keys
        valueSerializer - a serializer of values
        Throws:
        IllegalStateException - if this access is not valid
        See Also:
        StandardSerializers
      • getRawProofMap

        <K,​V> ProofMapIndexProxy<K,​V> getRawProofMap​(IndexAddress address,
                                                                 com.exonum.binding.common.serialization.Serializer<K> keySerializer,
                                                                 com.exonum.binding.common.serialization.Serializer<V> valueSerializer)
        Creates a new "raw" ProofMapIndex. A raw ProofMapIndex does not hash keys, hence imposes some requirements on them.
        Type Parameters:
        K - the type of keys in the map
        V - the type of values in the map
        Parameters:
        address - an index address in the MerkleDB
        keySerializer - a serializer of keys, must always produce 32-byte long values that suit the requirements
        valueSerializer - a serializer of values
        Throws:
        IllegalStateException - if this access is not valid
        See Also:
        getProofMap(IndexAddress, Serializer, Serializer), StandardSerializers
      • getMap

        <K,​V> MapIndexProxy<K,​V> getMap​(IndexAddress address,
                                                    com.exonum.binding.common.serialization.Serializer<K> keySerializer,
                                                    com.exonum.binding.common.serialization.Serializer<V> valueSerializer)
        Creates a new MapIndex.
        Type Parameters:
        K - the type of keys in the map
        V - the type of values in the map
        Parameters:
        address - an index address in the MerkleDB
        keySerializer - a serializer of keys
        valueSerializer - a serializer of values
        Throws:
        IllegalStateException - if this access is not valid
        See Also:
        getProofMap(IndexAddress, Serializer, Serializer), StandardSerializers
      • getKeySet

        <E> KeySetIndexProxy<E> getKeySet​(IndexAddress address,
                                          com.exonum.binding.common.serialization.Serializer<E> serializer)
        Creates a new KeySet.
        Type Parameters:
        E - the type of keys in this set
        Parameters:
        address - an index address in the MerkleDB
        serializer - a serializer of set keys
        Throws:
        IllegalStateException - if this access is not valid
        See Also:
        getValueSet(IndexAddress, Serializer), StandardSerializers
      • getValueSet

        <E> ValueSetIndexProxy<E> getValueSet​(IndexAddress address,
                                              com.exonum.binding.common.serialization.Serializer<E> serializer)
        Creates a new ValueSet.
        Type Parameters:
        E - the type of values in this set
        Parameters:
        address - an index address in the MerkleDB
        serializer - a serializer of set values
        Throws:
        IllegalStateException - if this access is not valid
        See Also:
        getKeySet(IndexAddress, Serializer), StandardSerializers
      • getProofEntry

        <E> ProofEntryIndex<E> getProofEntry​(IndexAddress address,
                                             com.exonum.binding.common.serialization.Serializer<E> serializer)
        Creates a new ProofEntry.
        Type Parameters:
        E - the type of the entry
        Parameters:
        address - an index address in the MerkleDB
        serializer - an entry serializer
        Throws:
        IllegalStateException - if this access is not valid
        See Also:
        StandardSerializers
      • getEntry

        <E> EntryIndex<E> getEntry​(IndexAddress address,
                                   com.exonum.binding.common.serialization.Serializer<E> serializer)
        Creates a new Entry.
        Type Parameters:
        E - the type of the entry
        Parameters:
        address - an index address in the MerkleDB
        serializer - an entry serializer
        Throws:
        IllegalStateException - if this access is not valid
        See Also:
        StandardSerializers
      • canModify

        boolean canModify()
        Returns true if this access allows modifications to the database state; false if it is immutable.
      • getAccessNativeHandle

        long getAccessNativeHandle()
        Returns a native handle of this access.
        Throws:
        IllegalStateException - if the access is invalid (closed or nullptr)