Hyperledger面料,如何在代言前与外部应用程序进行交互?

时间:2018-02-27 11:31:45

标签: hyperledger-fabric hyperledger

我有一个代码政策为-P 'OR (ORG1.peer, ORG2.peer)'的链码。当我使用命令peer chaincode invoke ...调用链码时,它只接受交易提议而没有任何中断或等待认可。换句话说:endorsement logic总是返回true。 根据{{​​3}}:

By default, endorsing logic at a peer accepts the tran-proposal and simply signs the tran-proposal. However, endorsing logic may interpret arbitrary functionality, to, e.g., interact with legacy systems with tran-proposal and tx as inputs to reach the decision whether to endorse a transaction or not.

现在我想覆盖这个逻辑,以便它在端口上侦听来自外部应用程序的接受或拒绝消息。

有可能吗?

如果是这样,我该怎么做?

我是否需要为fabric-peer构建自己的docker镜像?

我的认可逻辑waiting for an external call (ex. the administrator of organization)是否对现实世界的结构用例有意义?

1 个答案:

答案 0 :(得分:1)

通过执行智能合约(结构中的链码)来完成认可。 Chaincodes主要用Go,NodeJs和Java编写。

虽然不推荐(因为如果端点不受信任,它会使您的合同容易受到攻击),您可以访问驱动您的认可逻辑的任何外部应用程序(例如使用HTTP)。

合同的成功执行意味着运行您的链码的特定对等方已签署您的交易。例如,如果Org1对等体和Org2对等体成功运行了链码,那么您的交易中就有两个签名。

有关详细信息,请参阅这些文档:http://hyperledger-fabric.readthedocs.io/en/release/chaincode.html

http://hyperledger-fabric.readthedocs.io/en/release/endorsement-policies.html

http://hyperledger-fabric.readthedocs.io/en/release/txflow.html