Hyperledger结构:由于缺少配置数据,网络配置无效

时间:2018-09-05 11:11:12

标签: node.js hyperledger-fabric blockchain

我是超级账本结构和区块链的新手。到目前为止,我仍然可以配置和运行超级账本结构的示例,但是当我将余额转移中的“ Org1”重命名为“ Hospital”时,还添加了一个新组织“ Org3”。我可以运行该应用程序,但是在尝试向“医院”注册用户时,我面临以下问题。

network-config.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] [ERROR]助手-无法获得注册用户:Jim并出现错误:错误:由于缺少配置数据,网络配置无效   [2018-09-05 14:36:32.640] [DEBUG] SampleWebApp--为组织Hospital注册用户名Jim返回   [2018-09-05 14:36:32.640] [DEBUG] SampleWebApp-无法为组织医院的用户名Jim注册::失败错误:由于缺少配置数据,网络配置无效

2 个答案:

答案 0 :(得分:0)

添加新的组织后,您是否用新生成的密钥替换了/ keystore / key?如果不是,则需要相应组织密钥的更新路径。每当您生成加密配置时,“密钥”值都会更改。

答案 1 :(得分:0)

出现错误“ 由于缺少配置数据而导致网络配置无效 ”->我从 织物样品/余额转移< / em> 项目,您需要先为客户端即时设置配置设置,然后才能调用方法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'));