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 Details

  • Method Details

    • getName

      protected final String 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

      protected final ServiceInstanceSpec getInstanceSpec()
      Returns this service instance specification.
    • getStateHashes

      public List<HashCode> getStateHashes​(Snapshot snapshot)
      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 interface Service
      Parameters:
      snapshot - a snapshot of the blockchain state. Not valid after this method returns
      See Also:
      ProofListIndexProxy.getIndexHash(), ProofMapIndexProxy.getIndexHash()
    • createDataSchema

      protected abstract Schema createDataSchema​(View view)
      Creates a data schema of this service.
      Parameters:
      view - a database view
      Returns:
      a data schema of the service