gpt4 book ai didi

hyperledger-fabric - Hyperledger Fabric 中 channel 内和 channel 间的 Chaincode(智能合约)交互

转载 作者:行者123 更新时间:2023-12-04 07:58:04 26 4
gpt4 key购买 nike

如图所示,考虑 Hyperledger Fabric 网络中的组织对等设置。

enter image description here

组织 1 有两个对等点,组织 2 有一个对等点 - 所有这些都存在于同一个 channel 内 - X。组织 3 有一个存在于不同 channel 外部的对等点。

对等点具有不同的链码(c1、c2、c3 和 c4),并具有解释的功能。

write() - put a key-value pair into the ledger  
update() - update a value for an existing key
read() - query an existing key-value pair

现在来回答几个问题。
  • c3 可以调用 c2 来更新键的值吗(因为 c3 没有 update() 功能)?
  • c4 可以调用 c2 来更新键的值吗(因为 c4 没有 update() 功能)?
  • 可以 c3.read()查询c1.write()创建的数据?
    This link在链码教程上说“由链码创建的状态只限于该链码,不能被另一个链码直接访问”。这是否也适用于同一 channel 中的同行?根据我的理解,所有参与的同行都可以访问区块链分类账数据。
  • 可以 c4.read()查询c1.write()创建的数据?
  • 可以 c2.update()更新 c1.write() 创建的数据?
  • 最佳答案

    Peers 只能执行他们已经安装并有权访问(本地)的链码。您可以为给定的对等点拥有多个链码,但不能让对等点执行其他对等点的链码。

    来自 ChaincodeStub.invokeChaincode(chaincodeName, args, channel)文档位于 https://fabric-shim.github.io/ChaincodeStub.html#invokeChaincode__anchor :

    Locally calls the specified chaincode invoke() using the same transaction context; that is, chaincode calling chaincode doesn't create a new transaction message.



    您应该能够为所有对等点安装每个链码并使用 ChaincodeStub.invokeChaincode方法以及 ClientIdentity类( https://fabric-shim.github.io/ClientIdentity.html )来处理访问控制。

    关于hyperledger-fabric - Hyperledger Fabric 中 channel 内和 channel 间的 Chaincode(智能合约)交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51657142/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com