Class AbstractService

  • All Implemented Interfaces:
    Service

    public abstract class AbstractService
    extends Object
    implements Service
    A base class for user services.
    • Constructor Detail

      • AbstractService

        protected AbstractService​(short id,
                                  String name,
                                  TransactionConverter transactionConverter)
        Creates an AbstractService.
        Parameters:
        id - an id of the service
        name - a name of the service
        transactionConverter - a transaction converter that is aware of all transactions of this service
    • Method Detail

      • getId

        public short getId()
        Description copied from interface: Service
        Returns the id of the service.
        Specified by:
        getId in interface Service
      • getName

        public String getName()
        Description copied from interface: Service
        Returns the name of the service.
        Specified by:
        getName in interface Service
      • convertToTransaction

        public Transaction convertToTransaction​(RawTransaction rawTransaction)
        Description copied from interface: Service
        Converts an Exonum raw transaction to an executable transaction of this service.
        Specified by:
        convertToTransaction in interface Service
        Parameters:
        rawTransaction - a raw transaction to be converted
        Returns:
        an executable transaction
      • getStateHashes

        public List<HashCode> getStateHashes​(Snapshot snapshot)
        Description copied from interface: Service
        Returns a list of root hashes of all Merkelized tables defined by this service, as of the given snapshot of the blockchain state. If the service doesn't have any Merkelized tables, returns an empty list.

        The core uses this list to aggregate hashes of tables defined by 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.

        Specified by:
        getStateHashes in interface Service
        Parameters:
        snapshot - a snapshot of the blockchain state. Not valid after this method returns
        See Also:
        ProofListIndexProxy.getRootHash(), ProofMapIndexProxy.getRootHash()
      • 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