gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 19:58:43 25 4
gpt4 key购买 nike

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

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

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

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

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

但是,如果我在 invoke 函数中添加 await channel.initialize({ discovery: true, asLocalhost: true }) ,则此 initialize 函数抛出如下错误:

Error: No endorsement plan available for {"chaincodes":[{"name":"etri-bcdms-token-chaincode"}]}

(我在实例化期间设置了背书策略)

在peer中,打印以下日志:

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)

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

最佳答案

您必须在 channel 中的每个组织中添加一个 anchor ,这解决了我的问题。由于服务发现使用八卦协议(protocol),因此服务发现需要 anchor

关于hyperledger-fabric - 尝试初始化 Channel 对象以使用服务发现时无法获取背书计划,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54324870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com