Class UserServiceAdapter


  • public class UserServiceAdapter
    extends java.lang.Object
    An adapter of a user-facing interface Service to an interface with a native code.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterCommit​(long snapshotHandle, int validatorId, long height)
      Handles block committed event.
      void close()
      Close this service adapter.
      UserTransactionAdapter convertTransaction​(short transactionId, byte[] payload)
      Converts a transaction messages into an executable transaction of this service.
      short getId()  
      java.lang.String getName()  
      byte[][] getStateHashes​(long snapshotHandle)
      Returns the state hashes of the service.
      java.lang.String initialize​(long forkHandle)
      Returns the service initial global configuration.
      void mountPublicApiHandler​(long nodeNativeHandle)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getId

        public short getId()
      • getName

        public java.lang.String getName()
      • 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:
        java.lang.NullPointerException - if payload is null, or a user service returns a null transaction
        java.lang.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 java.lang.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.