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

标签 hyperledger-fabric blockchain hyperledger smartcontracts

如图所示,考虑 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/

    相关文章:

    java - INVOKE_CHAINCODE 失败 : transaction ID exists

    hyperledger-fabric - Hyperledger Fabric channel 创建失败

    docker - super 账本结构 : Understanding Docker Containers

    selenium-webdriver - 使用 Selenium webdriver 实现 Metamask 自动化

    node.js - 如何连接到 docker 容器的本地主机(从容器内部)

    hyperledger-fabric - 握手失败,出现 fatal error SSL_ERROR_SSL

    blockchain - Openzeppelin + Truffle 以太坊众筹购买代币()函数的前期成本可笑

    hyperledger-fabric - super 账本结构 : Error creating channelconfig bundle

    docker - 在本地运行hyperledger composer Playground 会导致错误

    hyperledger-fabric - 获取链码代码 mycc : path to chaincode does not exist 时出错