Class BlockchainData
public final class BlockchainData extends AbstractNativeProxy
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.
-
Field Summary
-
Method Summary
Modifier and Type Method Description IndexProof
createIndexProof(java.lang.String simpleIndexName)
Creates an index proof for an index of the executing service given the index simple name.java.util.Optional<Prefixed>
findServiceData(java.lang.String serviceName)
Returns a readonly database access for the data of the service instance with the given name, if it is started; orOptional.empty
if no such service started.static BlockchainData
fromHandle(long bdNativeHandle, Cleaner cleaner)
Creates a new BlockchainData from the native handle.static BlockchainData
fromRawAccess(AbstractAccess baseAccess, java.lang.String serviceName)
Creates a BlockchainData for the service with the given name.Blockchain
getBlockchain()
Returns the blockchain schema (aka Exonum core schema).DispatcherSchema
getDispatcherSchema()
Returns the schema of the dispatcher service.Prefixed
getExecutingServiceData()
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 Details
-
fromHandle
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, java.lang.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
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
Returns a readonly database access for the data of the service instance with the given name, if it is started; orOptional.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
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:
java.lang.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 processingjava.lang.IllegalArgumentException
- 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
Returns the blockchain schema (aka Exonum core schema). -
getDispatcherSchema
Returns the schema of the dispatcher service.
-