IBM Blockchain Platform Nodejs 客户端应用程序无法提交事务:没有为 MSP 'org1Admin' 定义的可从中发现的对等点
IBM Blockchain Platform Nodejs client app can't submit transaction: No peers defined for MSP 'org1Admin' to discover from
我已经在 IBM Blockchain Platform 云中部署了一个非常基本的 IBM Blockchain 网络:只有一个同级组织和一个排序者组织。我已经安装并实例化了一个非常基本的合约(只是 CRUD 操作),我现在正尝试使用模板 Nodejs 客户端应用程序为我的资产提交创建交易;这是我的代码:
'use strict';
const { FileSystemWallet, Gateway } = require('fabric-network');
const fs = require('fs');
const path = require('path');
async function main() {
try {
// Parse the connection profile. This would be the path to the file downloaded
// from the IBM Blockchain Platform operational console.
const ccpPath = path.resolve(__dirname, 'connection.json');
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
// Configure a wallet. This wallet must already be primed with an identity that
// the application can use to interact with the peer node.
const walletPath = path.resolve(__dirname, 'wallet');
const wallet = new FileSystemWallet(walletPath);
// Create a new gateway, and connect to the gateway peer node(s). The identity
// specified must already exist in the specified wallet.
const gateway = new Gateway();
await gateway.connect(ccp, { wallet: wallet, identity: 'orgAdmin' , discovery: {"enabled": true, "asLocalhost":false }});
// Get the network channel that the smart contract is deployed to.
const network = await gateway.getNetwork('erschannel');
// Get the smart contract from the network channel.
const contract = network.getContract('ers_contract');
// Submit the 'createCar' transaction to the smart contract, and wait for it
// to be committed to the ledger.
await contract.submitTransaction('createErsGenHash', 'ersGenHashId_1', 'ersGenHashId_1_value');
console.log('Transaction has been submitted');
await gateway.disconnect();
} catch (error) {
console.error(`Failed to submit transaction: ${error}`);
process.exit(1);
}
}
main();
我已经成功注册了身份 orgAdmin 并将其下载到我的本地钱包中(至少我做对了!!)。执行上述操作时出现以下错误:
C:\work\hlf>node invoke.js
2020-06-04T18:34:28.213Z - error: [Network]: _initializeInternalChannel: No peers defined for MSP 'orgAdmin' to discover from
Failed to submit transaction: Error: No peers defined for MSP 'orgAdmin' to discover from
这是我的 connection.json 配置文件(我从 IBM Blockchain Platform 控制台下载的);奇怪的是没有订购者信息:
{
"name": "ORG1MSPprofile",
"description": "Network on IBP v2",
"version": "1.0.0",
"client": {
"organization": "ORG1MSP"
},
"organizations": {
"ORG1MSP": {
"mspid": "ORG1MSP",
"certificateAuthorities": [
"184.172.233.238:31951"
],
"peers": [
"184.172.233.238:30604"
]
}
},
"peers": {
"184.172.233.238:30604": {
"url": "grpcs://184.172.233.238:30604",
"tlsCACerts": {
"pem": "-----BEGIN CERTIFICATE-----\nxxxxxxxxxxx\n-----END CERTIFICATE-----\n"
},
"grpcOptions": {
"ssl-target-name-override": "184.172.233.238"
}
}
},
"certificateAuthorities": {
"184.172.233.238:31951": {
"url": "https://184.172.233.238:31951",
"caName": "ca",
"tlsCACerts": {
"pem": "-----BEGIN CERTIFICATE-----\nxxxxxxxxxxx\n-----END CERTIFICATE-----\n"
}
}
}
}
我怀疑问题出在我配置 IBM 云区块链网络的方式上。我遵循了 here 中有关构建网络的官方教程。
你的问题的关键是这个错误信息
Error: No peers defined for MSP 'orgAdmin' to discover from
您已经在钱包中注册了您的身份,mspid 为 orgAdmin
。在您的连接配置文件中,定义的 mspid 是 ORG1MSP
"organizations": {
"ORG1MSP": {
"mspid": "ORG1MSP"
因此,当客户端试图找到一个与您选择的身份一起使用的对等点时,它会尝试找到一个属于组织的具有 mspid orgAdmin
的对等点,这在您的连接中不是已知的 mspid配置文件,因此会导致您看到错误消息。解决方案是删除并重新导入您的身份(或者只是从一个新钱包开始)并使用正确的 mspid 再次导入身份。
此外,连接配置文件中完全没有订购者列表。这称为动态连接配置文件,包含交互所需的最少信息。其他所需信息(例如其他节点和排序节点)是来自客户端 sdk 节点的 discovered
。正如您在代码中看到的那样,您已指定启用发现。
我已经在 IBM Blockchain Platform 云中部署了一个非常基本的 IBM Blockchain 网络:只有一个同级组织和一个排序者组织。我已经安装并实例化了一个非常基本的合约(只是 CRUD 操作),我现在正尝试使用模板 Nodejs 客户端应用程序为我的资产提交创建交易;这是我的代码:
'use strict';
const { FileSystemWallet, Gateway } = require('fabric-network');
const fs = require('fs');
const path = require('path');
async function main() {
try {
// Parse the connection profile. This would be the path to the file downloaded
// from the IBM Blockchain Platform operational console.
const ccpPath = path.resolve(__dirname, 'connection.json');
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
// Configure a wallet. This wallet must already be primed with an identity that
// the application can use to interact with the peer node.
const walletPath = path.resolve(__dirname, 'wallet');
const wallet = new FileSystemWallet(walletPath);
// Create a new gateway, and connect to the gateway peer node(s). The identity
// specified must already exist in the specified wallet.
const gateway = new Gateway();
await gateway.connect(ccp, { wallet: wallet, identity: 'orgAdmin' , discovery: {"enabled": true, "asLocalhost":false }});
// Get the network channel that the smart contract is deployed to.
const network = await gateway.getNetwork('erschannel');
// Get the smart contract from the network channel.
const contract = network.getContract('ers_contract');
// Submit the 'createCar' transaction to the smart contract, and wait for it
// to be committed to the ledger.
await contract.submitTransaction('createErsGenHash', 'ersGenHashId_1', 'ersGenHashId_1_value');
console.log('Transaction has been submitted');
await gateway.disconnect();
} catch (error) {
console.error(`Failed to submit transaction: ${error}`);
process.exit(1);
}
}
main();
我已经成功注册了身份 orgAdmin 并将其下载到我的本地钱包中(至少我做对了!!)。执行上述操作时出现以下错误:
C:\work\hlf>node invoke.js
2020-06-04T18:34:28.213Z - error: [Network]: _initializeInternalChannel: No peers defined for MSP 'orgAdmin' to discover from
Failed to submit transaction: Error: No peers defined for MSP 'orgAdmin' to discover from
这是我的 connection.json 配置文件(我从 IBM Blockchain Platform 控制台下载的);奇怪的是没有订购者信息:
{
"name": "ORG1MSPprofile",
"description": "Network on IBP v2",
"version": "1.0.0",
"client": {
"organization": "ORG1MSP"
},
"organizations": {
"ORG1MSP": {
"mspid": "ORG1MSP",
"certificateAuthorities": [
"184.172.233.238:31951"
],
"peers": [
"184.172.233.238:30604"
]
}
},
"peers": {
"184.172.233.238:30604": {
"url": "grpcs://184.172.233.238:30604",
"tlsCACerts": {
"pem": "-----BEGIN CERTIFICATE-----\nxxxxxxxxxxx\n-----END CERTIFICATE-----\n"
},
"grpcOptions": {
"ssl-target-name-override": "184.172.233.238"
}
}
},
"certificateAuthorities": {
"184.172.233.238:31951": {
"url": "https://184.172.233.238:31951",
"caName": "ca",
"tlsCACerts": {
"pem": "-----BEGIN CERTIFICATE-----\nxxxxxxxxxxx\n-----END CERTIFICATE-----\n"
}
}
}
}
我怀疑问题出在我配置 IBM 云区块链网络的方式上。我遵循了 here 中有关构建网络的官方教程。
你的问题的关键是这个错误信息
Error: No peers defined for MSP 'orgAdmin' to discover from
您已经在钱包中注册了您的身份,mspid 为 orgAdmin
。在您的连接配置文件中,定义的 mspid 是 ORG1MSP
"organizations": {
"ORG1MSP": {
"mspid": "ORG1MSP"
因此,当客户端试图找到一个与您选择的身份一起使用的对等点时,它会尝试找到一个属于组织的具有 mspid orgAdmin
的对等点,这在您的连接中不是已知的 mspid配置文件,因此会导致您看到错误消息。解决方案是删除并重新导入您的身份(或者只是从一个新钱包开始)并使用正确的 mspid 再次导入身份。
此外,连接配置文件中完全没有订购者列表。这称为动态连接配置文件,包含交互所需的最少信息。其他所需信息(例如其他节点和排序节点)是来自客户端 sdk 节点的 discovered
。正如您在代码中看到的那样,您已指定启用发现。