当调用链代码时,是否有办法调用 REST API(外部),以便可以通知客户端应用程序有关新交易的信息。
除了REST,还有其他选择吗?
最佳答案
最好使用事件 https://github.com/hyperledger/fabric/blob/master/docs/protocol-spec.md#35-events
Validating peers and chaincodes can emit events on the network that applications may listen for and take actions on. There is a set of pre-defined events, and chaincodes can generate custom events. Events are consumed by 1 or more event adapters. Adapters may further deliver events using other vehicles such as Web hooks or Kafka.
应用程序可以订阅来自 Fabric 的事件流并监听链代码生成的消息。
可以在此处找到有关如何使用事件的示例: https://github.com/hyperledger/fabric/tree/master/examples/events/block-listener
关于blockchain - 调用链代码时如何通知客户端应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40769741/