node.js - 超级账本结构:由于缺少配置数据,网络配置无效
问题描述
我是超级账本结构和区块链的新手。到目前为止,我能够配置和运行超级账本结构的示例,但是当我将余额转移中的“Org1”重命名为“Hospital”并添加了一个新组织“Org3”时。我能够运行该应用程序,但是在尝试将用户注册到“医院”时,我遇到了以下问题。
网络配置.json
{
"name":"balance-transfer",
"x-type":"hlfv1",
"description":"Balance Transfer Network",
"version":"1.0",
"channels":{
"mychannel":{
"orderers":[
"orderer.example.com"
],
"peers":{
"peer0.hospital.example.com":{
"endorsingPeer":true,
"chaincodeQuery":true,
"ledgerQuery":true,
"eventSource":true
},
"peer1.hospital.example.com":{
"endorsingPeer":false,
"chaincodeQuery":true,
"ledgerQuery":true,
"eventSource":false
},
"peer0.org2.example.com":{
"endorsingPeer":true,
"chaincodeQuery":true,
"ledgerQuery":true,
"eventSource":true
},
"peer0.org3.example.com":{
"endorsingPeer":true,
"chaincodeQuery":true,
"ledgerQuery":true,
"eventSource":true
}
},
"chaincodes":[
"mycc:v0"
]
}
},
"organizations":{
"Hospital":{
"mspid":"HospitalMSP",
"peers":[
"peer0.hospital.example.com",
"peer1.hospital.example.com"
],
"certificateAuthorities":[
"ca-hospital"
],
"adminPrivateKey":{
"path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/users/Admin@hospital.example.com/msp/keystore/key"
},
"signedCert":{
"path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/users/Admin@hospital.example.com/msp/signcerts/Admin@hospital.example.com-cert.pem"
}
},
"Org2":{
"mspid":"Org2MSP",
"peers":[
"peer0.org2.example.com"
],
"certificateAuthorities":[
"ca-org2"
],
"adminPrivateKey":{
"path":"artifacts/channel/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/key"
},
"signedCert":{
"path":"artifacts/channel/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem"
}
},
"Org3":{
"mspid":"Org3MSP",
"peers":[
"peer0.org3.example.com"
],
"certificateAuthorities":[
"ca-org3"
],
"adminPrivateKey":{
"path":"artifacts/channel/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/keystore/key"
},
"signedCert":{
"path":"artifacts/channel/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/signcerts/Admin@org3.example.com-cert.pem"
}
}
},
"orderers":{
"orderer.example.com":{
"url":"grpcs://localhost:7050",
"grpcOptions":{
"ssl-target-name-override":"orderer.example.com"
},
"tlsCACerts":{
"path":"artifacts/channel/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
}
}
},
"peers":{
"peer0.hospital.example.com":{
"url":"grpcs://localhost:7051",
"eventUrl":"grpcs://localhost:7053",
"grpcOptions":{
"ssl-target-name-override":"peer0.hospital.example.com"
},
"tlsCACerts":{
"path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/peers/peer0.hospital.example.com/tls/ca.crt"
}
},
"peer1.hospital.example.com":{
"url":"grpcs://localhost:7056",
"eventUrl":"grpcs://localhost:7058",
"grpcOptions":{
"ssl-target-name-override":"peer1.hospital.example.com"
},
"tlsCACerts":{
"path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/peers/peer1.hospital.example.com/tls/ca.crt"
}
},
"peer0.org2.example.com":{
"url":"grpcs://localhost:8051",
"eventUrl":"grpcs://localhost:8053",
"grpcOptions":{
"ssl-target-name-override":"peer0.org2.example.com"
},
"tlsCACerts":{
"path":"artifacts/channel/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
}
},
"peer0.org3.example.com":{
"url":"grpcs://localhost:9051",
"eventUrl":"grpcs://localhost:9053",
"grpcOptions":{
"ssl-target-name-override":"peer0.org3.example.com"
},
"tlsCACerts":{
"path":"artifacts/channel/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt"
}
}
},
"certificateAuthorities":{
"ca-hospital":{
"url":"https://localhost:7054",
"httpOptions":{
"verify":false
},
"tlsCACerts":{
"path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/ca/ca.hospital.example.com-cert.pem"
},
"registrar":[
{
"enrollId":"admin",
"enrollSecret":"adminpw"
}
],
"caName":"ca-hospital"
},
"ca-org2":{
"url":"https://localhost:8054",
"httpOptions":{
"verify":false
},
"tlsCACerts":{
"path":"artifacts/channel/crypto-config/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem"
},
"registrar":[
{
"enrollId":"admin",
"enrollSecret":"adminpw"
}
],
"caName":"ca-org2"
},
"ca-org3":{
"url":"https://localhost:9054",
"httpOptions":{
"verify":false
},
"tlsCACerts":{
"path":"artifacts/channel/crypto-config/peerOrganizations/org3.example.com/ca/ca.org3.example.com-cert.pem"
},
"registrar":[
{
"enrollId":"admin",
"enrollSecret":"adminpw"
}
],
"caName":"ca-org3"
}
}
}
[2018-09-05 14:36:32.640] [错误] 帮助程序 - 无法获取注册用户:Jim 错误:错误:由于缺少配置数据,网络配置无效 [2018-09-05 14:36:32.640] [ DEBUG] SampleWebApp - -- 从为组织医院注册用户名 Jim 返回 [2018-09-05 14:36:32.640] [DEBUG] SampleWebApp - 无法为组织医院注册用户名 Jim 与::failed 错误:无效的网络配置由于缺少配置数据
解决方案
出现错误“由于缺少配置数据而导致网络配置无效”->正如我从fabric-samples/balance-transfer项目中知道的那样,您需要为客户端即时设置配置设置,然后才能调用方法 loadFromConfig。
这是您可以在fabric-sample/balance-transer项目的文件config.js中找到的一些代码
var hfc = require('fabric-client');
hfc.setConfigSetting('network-connection-profile-path',path.join(__dirname, 'artifacts' ,file));//file here is your network connection profile
hfc.setConfigSetting('Org1-connection-profile-path',path.join(__dirname, 'artifacts', 'org1.yaml'));
hfc.setConfigSetting('Org2-connection-profile-path',path.join(__dirname, 'artifacts', 'org2.yaml'));
在文件helper.js 中,您将看到客户端调用方法 loadFromConfig 如下
client.loadFromConfig(hfc.getConfigSetting('network-connection-profile-path'));
推荐阅读
- asp.net - 为什么我不能将文件发送到服务器?
- python - 如何在python中增加一个包含数字和字符的列表?
- java - Java 异常 - 块溢出
- youtube - 从 API 获取 Youtube 频道缩略图
- angular - Angular2 或更高版本中的 JQuery Trigger 等效项
- sql - SQL Server 插入下一列
- sql - 带有 enum('a','b','c') 的 'a' 附近的语法不正确
- python - 在python中实现sigmoid函数
- css - 具有响应大小和固定 px 边距的图像对齐
- kubernetes - 哪个k8s数据结构来表示基本对象?