2通道之间的通信
Communication between 2 channels
Hyperledger 社区大家好,
所以我用 Hyperledger Fabric 测试了一些东西,我想知道是否有可能让 2 个通道在某种程度上共享信息。
例如,假设我们有 3 个组织 Org1、Org2 和 Org3。
Org1 和 Org3 是经销商,Org2 是托运人。
Org2 通过通道 2-1 与 Org1 通信,Org2 通过通道 2-3 与 Org3 通信。但是 Org1 和 Org3 不能相互通信,因为它们不共享任何业务。
但是 Org2 希望将所有这些信息保存在一个且唯一的分类帐中,因为通过查看一个分类帐比一直查看两个不同的分类帐更容易处理数据。
那么有没有一种方法可以让 Org2 拥有一个专供自己使用的通道,即通道 2,并在 Org2 在通道 2-1 和 2-3 上接收或创建交易时自动在其上创建交易?
例如,假设 Org1 通过频道 2-1 订购了 20 辆汽车 (id #A1598),Org3 通过频道 2-3 订购了 2 吨土豆 (id #B502)。有没有办法让 Channel 2 也自动获取这些数据?这样交易也写在上面,如果有一天有问题,可以指导 Org2 检查 Channel 2-1 上的交易。
当 Org2 为所有事务请求 Channel2 时,会出现类似这样的情况:
[{
id: 'A1598',
channel: '2-1',
org: 'Org1',
details: '20 cars',
price: 'xxxxx$'
},
{
id: 'B502',
channel: '2-3',
org: 'Org3',
details: '2 tons of potatoes',
price: 'xxxxx$'
}]
自动对在一个渠道中完成的交易做出反应并在另一个渠道中做某事是事件的一个很好的用例。
链码示例:
eventPayload := "Order requested by Org1" + someOtherPayload
payloadAsBytes := []byte(eventPayload)
stub.SetEvent("Order requested", payloadAsBytes)
因此将其投影到您的示例中:
For example, let's say Org1 has made an order (id #A1598) of 20 cars through Channel 2-1 and Org3 has made an order (id #B502) of 2 tons of potatoes through Channel 2-3. Is there a way for Channel 2 to get automatically those data too ?
当 org1(经销商)订购 20 辆汽车时,它会在链码中发出一个事件(例如 "order requested" 上方),您可以从您后端的 org2 用户那里收听此事件,该用户是该频道的注册会员.现在 org3 创建订单时,还会发出一个事件 ("order requested")。现在,org2 的已注册用户也可以访问 org1 的通道,可以在此通道上询问新交易是否超过当天的限制,并可以做出相应的反应。
请参阅 node 的示例教程。或者只搜索适合您的编程语言的相应教程。
Hyperledger 社区大家好,
所以我用 Hyperledger Fabric 测试了一些东西,我想知道是否有可能让 2 个通道在某种程度上共享信息。
例如,假设我们有 3 个组织 Org1、Org2 和 Org3。
Org1 和 Org3 是经销商,Org2 是托运人。
Org2 通过通道 2-1 与 Org1 通信,Org2 通过通道 2-3 与 Org3 通信。但是 Org1 和 Org3 不能相互通信,因为它们不共享任何业务。
但是 Org2 希望将所有这些信息保存在一个且唯一的分类帐中,因为通过查看一个分类帐比一直查看两个不同的分类帐更容易处理数据。
那么有没有一种方法可以让 Org2 拥有一个专供自己使用的通道,即通道 2,并在 Org2 在通道 2-1 和 2-3 上接收或创建交易时自动在其上创建交易?
例如,假设 Org1 通过频道 2-1 订购了 20 辆汽车 (id #A1598),Org3 通过频道 2-3 订购了 2 吨土豆 (id #B502)。有没有办法让 Channel 2 也自动获取这些数据?这样交易也写在上面,如果有一天有问题,可以指导 Org2 检查 Channel 2-1 上的交易。
当 Org2 为所有事务请求 Channel2 时,会出现类似这样的情况:
[{
id: 'A1598',
channel: '2-1',
org: 'Org1',
details: '20 cars',
price: 'xxxxx$'
},
{
id: 'B502',
channel: '2-3',
org: 'Org3',
details: '2 tons of potatoes',
price: 'xxxxx$'
}]
自动对在一个渠道中完成的交易做出反应并在另一个渠道中做某事是事件的一个很好的用例。
链码示例:
eventPayload := "Order requested by Org1" + someOtherPayload
payloadAsBytes := []byte(eventPayload)
stub.SetEvent("Order requested", payloadAsBytes)
因此将其投影到您的示例中:
For example, let's say Org1 has made an order (id #A1598) of 20 cars through Channel 2-1 and Org3 has made an order (id #B502) of 2 tons of potatoes through Channel 2-3. Is there a way for Channel 2 to get automatically those data too ?
当 org1(经销商)订购 20 辆汽车时,它会在链码中发出一个事件(例如 "order requested" 上方),您可以从您后端的 org2 用户那里收听此事件,该用户是该频道的注册会员.现在 org3 创建订单时,还会发出一个事件 ("order requested")。现在,org2 的已注册用户也可以访问 org1 的通道,可以在此通道上询问新交易是否超过当天的限制,并可以做出相应的反应。
请参阅 node 的示例教程。或者只搜索适合您的编程语言的相应教程。