Interface CommitHandler
public interface CommitHandler
Class to handle waiting for an appropriate number of successful commit events to be received from peers following
submit of a transaction to the orderer. Each handler instance will handle a single transaction so can maintain
instance state related to events received during its lifetime.
Implementations may use Network.addCommitListener(CommitListener, java.util.Collection, String)
to identify when specific peers have committed the transaction they are tracking.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Called to interrupt the waiting state ofwaitForEvents(long, TimeUnit)
before completion.void
Called to initiate listening for transaction events.void
waitForEvents
(long timeout, TimeUnit timeUnit) Block until enough transaction commit events have been received to satisfy the event handling strategy.
-
Method Details
-
startListening
void startListening()Called to initiate listening for transaction events. -
waitForEvents
void waitForEvents(long timeout, TimeUnit timeUnit) throws ContractException, TimeoutException, InterruptedException Block until enough transaction commit events have been received to satisfy the event handling strategy.- Parameters:
timeout
- the maximum time to wait.timeUnit
- the time unit of the timeout argument.- Throws:
ContractException
- if the commit fails, either by being rejected by a peer of failing to meet the requirements of the strategy.TimeoutException
- if the strategy was not satisfied in time.InterruptedException
- if the current thread is interrupted while waiting.
-
cancelListening
void cancelListening()Called to interrupt the waiting state ofwaitForEvents(long, TimeUnit)
before completion.
-