使用HyperledgerComposerV0.12使用以下代码调用deploy函数,这将返回一个“成功”结果:
/**
* Deploys a new BusinessNetworkDefinition to the Hyperledger Fabric. The connection must be connected for this method to succeed.
* @param {express.req} req - the inbound request object from the client
* req.body.myArchive: _string - string name of object
* req.body.deployOptions: _object - string name of object
* @param {express.res} res - the outbound response object for communicating back to client
* @param {express.next} next - an express service to enable post processing prior to responding to the client
* returns composerAdmin.connection - either an error or a connection object
* @function
*/
exports.deploy = function(req, res, next) {
let newFile = path.join(path.dirname(require.main.filename),'network/dist',req.body.myArchive);
let archiveFile = fs.readFileSync(newFile);
let adminConnection = new composerAdmin.AdminConnection();
return BusinessNetworkDefinition.fromArchive(archiveFile)
.then(function(archive) {
adminConnection.connect(config.composer.connectionProfile, config.composer.adminID, config.composer.adminPW)
.then(function(){
adminConnection.deploy(archive)
.then(function(){
console.log('business network '+req.body.myArchive+' deployed successful: ');
res.send({deploy: req.body.myArchive+' deploy succeeded'});
})
.catch(function(error){
console.log('business network '+req.body.myArchive+' deploy failed: ',error);
res.send({deploy: error});
});
});
});
};但是,当我介绍以下过程时:
我得到以下结果:
[2] at: 08:10:36.058 Url is: /composer/admin/ping
network ping successful: { version: '0.12.0', participant: null }
[3] at: 08:11:05.503 Url is: /composer/admin/undeploy
zerotoblockchain-network network undeploy successful
[4] at: 08:11:25.186 Url is: /composer/admin/ping
(node:18241) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error trying to ping. Error: Error trying to query chaincode. Error: chaincode error (status: 500, message: Error: The business network has been undeployed)
[5] at: 08:11:34.393 Url is: /composer/admin/deploy
business network zerotoblockchain-network.bna deployed successful:
[6] at: 08:11:44.211 Url is: /composer/admin/ping
(node:18241) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Error trying to ping. Error: Error trying to query chaincode. Error: chaincode error (status: 500, message: Error: The business network has been undeployed)这表明composer部署函数实际上并没有部署网络,尽管我似乎从部署服务收到了成功的完成消息。救命求你了?
发布于 2017-09-07 07:52:33
当您取消部署业务网络时,它所做的就是将业务网络标记为不可访问。它仍在部署并仍在运行。原因是目前Hyperledger fabric没有提供关闭实例化链码的机制。所以我们所能做的就是把它标记为不可用。deploy和命令是建立和运行业务网络的老方法。新方法是安装/启动组合。deploy成功的原因是,它必须对install命令报告的错误做出决定,才能继续以Hyperledger结构的预期方式工作。因此,尽管它报告了部署的成功,但它实际上什么也不做,因为它已经部署了。
https://stackoverflow.com/questions/46075129
复制相似问题