Class UserServiceAdapter
- java.lang.Object
-
- com.exonum.binding.core.service.adapters.UserServiceAdapter
-
-
Constructor Summary
Constructors Constructor Description UserServiceAdapter(Service service, Server server, ViewFactory viewFactory)
-
Method Summary
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()
String
getName()
Service
getService()
byte[][]
getStateHashes(long snapshotHandle)
Returns the state hashes of the service.String
initialize(long forkHandle)
Returns the service initial global configuration.void
mountPublicApiHandler(long nodeNativeHandle)
-
-
-
Constructor Detail
-
UserServiceAdapter
@Inject public UserServiceAdapter(Service service, Server server, ViewFactory viewFactory)
-
-
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 transactionpayload
- a transaction payload- Returns:
- an executable transaction of this service
- Throws:
NullPointerException
- if payload is null, or a user service returns a null transactionIllegalArgumentException
- 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 objectvalidatorId
- a validator id. Negative if this node is not a validatorheight
- the current blockchain height
-
close
public void close()
Close this service adapter.Releases any resources.
-
-