org.hyperledger.fabric.gateway.spi

## 接口 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.

  另请参阅:
    SampleCommitHandlerFactory, SampleCommitHandler

- - ### 方法概要

    所有方法 实例方法 抽象方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `cancelListening()` Called to interrupt the waiting state of `waitForEvents(long, TimeUnit)` before completion.
    `void` | `startListening()` 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.

- - ### 方法详细资料

    - #### 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.
      参数:
        `timeout` - the maximum time to wait.
        `timeUnit` - the time unit of the timeout argument.
      抛出:
        `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 of `waitForEvents(long, TimeUnit)` before completion.

Copyright © 2023. All rights reserved.