hyperledger-fabric - 如何从另一个渠道获取查询结果
问题描述
当我想在我的结构中获取查询结果时遇到了麻烦。我有 2 个频道,频道 1 存储帐户数据,频道 2 存储一些内容及其成本。我在频道1,我想在频道2中查询一个内容的费用,然后在频道1中“购买”它。例如,频道1有一个帐户A,他有20美元,频道2有一个电影费用9美元,A想查询电影的成本,然后“购买”它,所以 A 现在只有 11 美元。但现在我不知道如何从 channel2 获得“$9”。我该怎么做?
解决方案
Fabric 使用通道作为一种隔离形式。如何使用“InvokeChaincode”API 调用另一个链码。
// InvokeChaincode locally calls the specified chaincode `Invoke` using the
// same transaction context; that is, chaincode calling chaincode doesn't
// create a new transaction message.
// If the called chaincode is on the same channel, it simply adds the called
// chaincode read set and write set to the calling transaction.
// If the called chaincode is on a different channel,
// only the Response is returned to the calling chaincode; any PutState calls
// from the called chaincode will not have any effect on the ledger; that is,
// the called chaincode on a different channel will not have its read set
// and write set applied to the transaction. Only the calling chaincode's
// read set and write set will be applied to the transaction. Effectively
// the called chaincode on a different channel is a `Query`, which does not
// participate in state validation checks in subsequent commit phase.
// If `channel` is empty, the caller's channel is assumed.
InvokeChaincode(chaincodeName string, args [][]byte, channel string) pb.Response
推荐阅读
- neo4j - 随机化节点之间的关系
- r - 如何使用 R 抓取某些(过滤排序的)twitter 关注者
- elasticsearch - 条件 Kibana 索引阈值警报
- python - 无法直接在 Mac 上的终端中运行 Jupyter notebook
- java - 通过标签或标签查找 java 类
- python - Python的Group By技术与SQL partition by的比较
- html - webkit-line-clamp:限制没有省略号的行数
- botframework - 如何在 Bot Framework v2.0 上开发自定义操作
- php - 在 razorpay 的服务器上找不到请求的 URL
- javascript - 如何在打字稿中触发调整大小事件