Class BlockchainData


  • public final class BlockchainData
    extends AbstractNativeProxy
    Provides access to blockchain data of a particular service instance.

    The service instance data is accessible via a Prefixed access which isolates the service data from all the other instances.

    On top of that, this class provides read-only access to persistent data of:

    • Exonum Core
    • Dispatcher Service
    • Other services.

    As most native proxies, BlockchainData works in a scope that is usually managed by the framework. When that scope is closed, the BlockchainData becomes inaccessible. All accesses and indexes created with them also become inaccessible.

    • Method Detail

      • fromHandle

        public static BlockchainData fromHandle​(long bdNativeHandle,
                                                Cleaner cleaner)
        Creates a new BlockchainData from the native handle. The destructor will be registered in the given cleaner.
        Parameters:
        bdNativeHandle - a handle of the native BlockchainData object
        cleaner - a cleaner to destroy the native peer and any dependent objects
      • fromRawAccess

        public static BlockchainData fromRawAccess​(AbstractAccess baseAccess,
                                                   String serviceName)
        Creates a BlockchainData for the service with the given name.
        Parameters:
        baseAccess - the base database access, must be a "RawAccess"
        serviceName - a service instance name
      • getExecutingServiceData

        public Prefixed getExecutingServiceData()
        Returns the database access for the data of the current executing service.

        The returned Access is writeable in contexts that allow database modifications.

        Only service data is accessible through the returned access. All indexes, initialized through this access, are created in a namespace, separate from other services. The namespace is equal to the executing service name.

      • findServiceData

        public Optional<Prefixed> findServiceData​(String serviceName)
        Returns a readonly database access for the data of the service instance with the given name, if it is started; or Optional.empty if no such service started.

        Only service data is accessible through the returned access.

        The namespace is equal to the service instance name.

        Parameters:
        serviceName - the name of the service instance to which data to provide access
      • createIndexProof

        public IndexProof createIndexProof​(String simpleIndexName)
        Creates an index proof for an index of the executing service given the index simple name.
        Parameters:
        simpleIndexName - the name of the index for which to create a proof
        Throws:
        IllegalStateException - if the blockchain data is not based on a snapshot, because a state of a service index can be proved only for the latest committed block, not for any intermediate state during transaction processing
        IllegalArgumentException - if the index with the given name does not exist; or is not Merkelized. See Blockchain.createIndexProof(String) for details.
        See Also:
        Blockchain.createIndexProof(String)
      • getBlockchain

        public Blockchain getBlockchain()
        Returns the blockchain schema (aka Exonum core schema).
      • getDispatcherSchema

        public DispatcherSchema getDispatcherSchema()
        Returns the schema of the dispatcher service.