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

问题描述 投票:3回答:1

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

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

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

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

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

但是,如果我在await channel.initialize({ discover: true, asLocalhost: true })函数中添加了invoke,则此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

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

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)

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

hyperledger-fabric hyperledger hyperledger-fabric-sdk-js
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.