尝试初始化 Channel 对象以使用服务发现时无法获得背书计划

byr*_*1st 5 hyperledger hyperledger-fabric hyperledger-fabric-sdk-js

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

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

await channel.initialize({ discover: true, asLocalhost: true })
Run Code Online (Sandbox Code Playgroud)

按照fabric-node-sdk文档中的教程,我更改了每个peer的端口以在docker-compose网络中使用服务发现。

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

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

Error: No endorsement plan available for {"chaincodes":[{"name":"etri-bcdms-token-chaincode"}]}
Run Code Online (Sandbox Code Playgroud)

(我在实例化过程中设置了我的背书策略)

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

Failed constructing descriptor for chaincode chaincodes:<name:"etri-bcdms-token-chaincode" > ,: cannot satisfy any principal combination
Run Code Online (Sandbox Code Playgroud)

我的调用函数的完整代码如下:

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)
Run Code Online (Sandbox Code Playgroud)

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

Mor*_*rty 2

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