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.- See Also:
- SampleCommitHandlerFactory, SampleCommitHandler
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cancelListening()
Called to interrupt the waiting state ofwaitForEvents(long, TimeUnit)
before completion.void
startListening()
Called to initiate listening for transaction events.void
waitForEvents(long timeout, java.util.concurrent.TimeUnit timeUnit)
Block until enough transaction commit events have been received to satisfy the event handling strategy.
-
-
-
Method Detail
-
startListening
void startListening()
Called to initiate listening for transaction events.
-
waitForEvents
void waitForEvents(long timeout, java.util.concurrent.TimeUnit timeUnit) throws ContractException, java.util.concurrent.TimeoutException, java.lang.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.java.util.concurrent.TimeoutException
- if the strategy was not satisfied in time.java.lang.InterruptedException
- if the current thread is interrupted while waiting.
-
cancelListening
void cancelListening()
Called to interrupt the waiting state ofwaitForEvents(long, TimeUnit)
before completion.
-
-