使用Hyperledger Composer V0.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)
这表明作曲家部署功能实际上并未部署网络,即使我似乎从部署服务收到成功的完成消息。请帮帮忙?
答案 0 :(得分:2)
取消部署业务网络时,它所做的只是将业务网络标记为无法访问。它仍然部署并仍在运行。原因是目前Hyperledger结构没有提供关闭实例化链代码的机制。所以我们所能做的就是将其标记为无法使用。 部署API和命令是启动和运行业务网络的旧方法。新方法是安装/启动组合。部署报告成功的原因是它必须决定安装和启动命令报告的错误,以便继续以Hyperledger Fabric的方式以预期的方式工作。因此,尽管它报告了部署成功,但由于它已经部署,它实际上什么都不做。