Class BlockchainData
- java.lang.Object
-
- com.exonum.binding.core.proxy.AbstractNativeProxy
-
- com.exonum.binding.core.blockchain.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
Prefixedaccess 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.
-
-
Field Summary
-
Fields inherited from class com.exonum.binding.core.proxy.AbstractNativeProxy
nativeHandle
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexProofcreateIndexProof(String simpleIndexName)Creates an index proof for an index of the executing service given the index simple name.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; orOptional.emptyif no such service started.static BlockchainDatafromHandle(long bdNativeHandle, Cleaner cleaner)Creates a new BlockchainData from the native handle.static BlockchainDatafromRawAccess(AbstractAccess baseAccess, String serviceName)Creates a BlockchainData for the service with the given name.BlockchaingetBlockchain()Returns the blockchain schema (aka Exonum core schema).DispatcherSchemagetDispatcherSchema()Returns the schema of the dispatcher service.PrefixedgetExecutingServiceData()Returns the database access for the data of the current executing service.-
Methods inherited from class com.exonum.binding.core.proxy.AbstractNativeProxy
getNativeHandle, isValidHandle
-
-
-
-
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 objectcleaner- 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; orOptional.emptyif 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 processingIllegalArgumentException- if the index with the given name does not exist; or is not Merkelized. SeeBlockchain.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.
-
-