Package com.exonum.binding.core.service
Class AbstractService
java.lang.Object
com.exonum.binding.core.service.AbstractService
- All Implemented Interfaces:
Service
public abstract class AbstractService extends Object implements Service
A base class for user services.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractService(ServiceInstanceSpec instanceSpec)
-
Method Summary
Modifier and Type Method Description protected abstract Schema
createDataSchema(View view)
Creates a data schema of this service.protected int
getId()
Returns the numeric id of the service instance.protected ServiceInstanceSpec
getInstanceSpec()
Returns this service instance specification.protected String
getName()
Returns the name of the service instance.List<HashCode>
getStateHashes(Snapshot snapshot)
Returns a list of hashes representing the state of this service, as of the given snapshot of the blockchain state.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.exonum.binding.core.service.Service
afterCommit, beforeCommit, createPublicApiHandlers, initialize
-
Constructor Details
-
Method Details
-
getName
Returns the name of the service instance.- See Also:
ServiceInstanceSpec.getName()
-
getId
protected final int getId()Returns the numeric id of the service instance.- See Also:
ServiceInstanceSpec.getId()
-
getInstanceSpec
Returns this service instance specification. -
getStateHashes
Description copied from interface:Service
Returns a list of hashes representing the state of this service, as of the given snapshot of the blockchain state. Usually, it includes the hashes of all Merkelized collections defined by this service.The core uses this list to verify that the service on each node in the network has the same database state. To do so efficiently, it aggregates state hashes of all services into a single Merkelized meta-map. The hash of this meta-map is considered the hash of the entire blockchain state and is recorded as such in blocks and Precommit messages.
Please note that if this service does not provide any state hashes, the framework will not be able to verify that its transactions cause the same results on different nodes.
- Specified by:
getStateHashes
in interfaceService
- Parameters:
snapshot
- a snapshot of the blockchain state. Not valid after this method returns- See Also:
ProofListIndexProxy.getIndexHash()
,ProofMapIndexProxy.getIndexHash()
-
createDataSchema
Creates a data schema of this service.- Parameters:
view
- a database view- Returns:
- a data schema of the service
-