Class UserServiceAdapter


  • public class UserServiceAdapter
    extends Object
    An adapter of a user-facing interface Service to an interface with a native code.
    • Constructor Detail

    • Method Detail

      • getId

        public short getId()
      • getName

        public String getName()
      • getService

        public Service getService()
      • convertTransaction

        public UserTransactionAdapter convertTransaction​(short transactionId,
                                                         byte[] payload)
        Converts a transaction messages into an executable transaction of this service.

        The callee must handle the declared exceptions.

        Parameters:
        transactionId - an identifier of the transaction
        payload - a transaction payload
        Returns:
        an executable transaction of this service
        Throws:
        NullPointerException - if payload is null, or a user service returns a null transaction
        IllegalArgumentException - if message is not a valid transaction message of this service
      • getStateHashes

        public byte[][] getStateHashes​(long snapshotHandle)
        Returns the state hashes of the service.

        The method does not destroy a native snapshot object corresponding to the passed handle.

        Parameters:
        snapshotHandle - a handle to a native snapshot object
        Returns:
        an array of state hashes
        See Also:
        Service.getStateHashes(Snapshot)
      • initialize

        @Nullable
        public String initialize​(long forkHandle)
        Returns the service initial global configuration.

        The method does not destroy a native fork object corresponding to the passed handle.

        Parameters:
        forkHandle - a handle to a native fork object
        Returns:
        the service global configuration as a JSON string or null if it does not have any
        See Also:
        Service.initialize(Fork)
      • mountPublicApiHandler

        public void mountPublicApiHandler​(long nodeNativeHandle)
      • afterCommit

        public void afterCommit​(long snapshotHandle,
                                int validatorId,
                                long height)
        Handles block committed event. This handler is invoked after commit of the block.
        Parameters:
        snapshotHandle - a handle to a native snapshot object
        validatorId - a validator id. Negative if this node is not a validator
        height - the current blockchain height
      • close

        public void close()
        Close this service adapter.

        Releases any resources.