Hyperledger fabric 尝试初始化通道对象以使用服务发现时无法获取认可计划

Hyperledger fabric 尝试初始化通道对象以使用服务发现时无法获取认可计划,hyperledger-fabric,hyperledger,hyperledger-fabric-sdk-js,Hyperledger Fabric,Hyperledger,Hyperledger Fabric Sdk Js,我正在尝试使用Fabric 1.4中的服务发现功能。默认为“我的网络”,每个组织有2个组织和2个对等点。我尝试通过服务发现功能调用链码,而不是设置特定的目标对等点。(在使用服务发现之前,我在transaction proposal request对象的目标属性中设置了特定的背书人。) 要使用服务发现,我在连接配置文件中将discover:true设置为对等方。然后,我简单地将下面的代码添加到我的invoke函数中 await channel.initialize({ discover: true

我正在尝试使用Fabric 1.4中的服务发现功能。默认为“我的网络”,每个组织有2个组织和2个对等点。我尝试通过服务发现功能调用链码,而不是设置特定的目标对等点。(在使用服务发现之前,我在transaction proposal request对象的目标属性中设置了特定的背书人。)

要使用服务发现,我在连接配置文件中将
discover:true
设置为对等方。然后,我简单地将下面的代码添加到我的
invoke
函数中

await channel.initialize({ discover: true, asLocalhost: true })
按照fabric node sdk文档中的教程,我在
docker compose
network中更改了每个对等节点的端口,以使用服务发现

一切正常,包括创建频道、安装链码和实例化链码。此外,如果我没有使用服务发现功能,调用链码也可以正常工作

但是,如果我在我的
invoke
函数中添加了
wait channel.initialize({discover:true,asLocalhost:true})
,此
initialize
函数会抛出如下错误:

Error: No endorsement plan available for {"chaincodes":[{"name":"etri-bcdms-token-chaincode"}]}
(我在实例化过程中设置了我的背书策略)

在对等机中,打印以下日志:

Failed constructing descriptor for chaincode chaincodes:<name:"etri-bcdms-token-chaincode" > ,: cannot satisfy any principal combination

对于这种错误有什么建议吗?我可以在哪里投资来修复此错误并使用服务发现?任何建议都将非常感谢。

您必须在频道中的每个组织中添加一个锚节点,这为我解决了问题。由于服务发现使用八卦协议,因此需要锚节点进行服务发现

您是否找到了导致此问题的原因?我也有类似的问题。节点链码进行部署和实例化,但由于发现服务出现问题,调用失败。错误是:
无法为chaincode构建描述符chaincodes:,:无法满足任何主要组合
如何专门添加锚节点。使用
channel.addPeer()。还有
channel.initialize()
的用途是什么?因此我知道如何使用cli容器来完成这项工作,大约在本文介绍的页面的一半,但我不知道如何使用node sdk,这正是我想要签出此存储库的内容,特别是这个文件-。我正在学习使用NodeSDK,方法是遵循这里定义的函数,然后是1.4.1文档。似乎
initialize
函数本身什么都不做。它只是“唤醒”了一个对等的容器?谢谢你的分享,但我仍然看不到锚节点被添加到哪里。添加锚定对等点需要通道更新,其中输入参数是锚定
*。tx
update变量
defaultPeer
上方的几行是此示例的锚定对等点。但是,以
.tx
结尾的锚点对等配置文件也是我不确定的。此示例工作正常,在任何时候都不引用该文件。
const client = this._useFabricCA
      ? await getUserClient(orgID, userID)
      : await getOrgAdminClient(orgID)
    if (!client) {
      throw Error(`failed to get the client for ${orgID}`)
    }

    const channel = client.getChannel(channelID)
    if (!channel) {
      throw Error(`failed to get the channel for ${channelID}`)
    }

    // Service discovery
    await channel.initialize({ discover: true, asLocalhost: true })

    const chaincodeSetting = getChaincodeSetting(channelID)
    if (!chaincodeSetting) {
      throw Error(`no chaincode set on the channel ${channelID}`)
    }

    const txID = client.newTransactionID()
    const request: ChaincodeInvokeRequest = {
      // targets: targetList,
      chaincodeId: chaincodeSetting.id,
      fcn,
      args,
      txId: txID
    }

    // Process the endorsement
    const results = await channel.sendTransactionProposal(request)