deploy_synchronously

This commit is contained in:
Aakil Fernandes 2015-11-20 13:02:18 -05:00 committed by Aakil Fernandes
parent bd76193ac8
commit 7dac3c0832
2 changed files with 27 additions and 2 deletions

View File

@ -54,7 +54,9 @@ BlockchainConfig.prototype.config = function(env) {
whisper: config.whisper || false, whisper: config.whisper || false,
account: config.account, account: config.account,
geth_extra_opts: config.geth_extra_opts || [], geth_extra_opts: config.geth_extra_opts || [],
testnet: config.testnet || false testnet: config.testnet || false,
geth_extra_opts: config.geth_extra_opts,
deploy_synchronously: config.deploy_synchronously || false
} }
return config; return config;

View File

@ -54,7 +54,10 @@ Deploy.prototype.deploy_contracts = function(env, cb) {
this.contractDB = this.contractsManager.contractDB; this.contractDB = this.contractsManager.contractDB;
this.deployedContracts = {}; this.deployedContracts = {};
this.deploy_contract_list(all_contracts.length, env, all_contracts, cb); if(this.blockchainConfig.deploy_synchronously)
this.deploy_contract_list_sync(env, all_contracts, cb);
else
this.deploy_contract_list(all_contracts.length, env, all_contracts, cb);
} }
Deploy.prototype.deploy_contract_list = function(index, env, all_contracts, cb) { Deploy.prototype.deploy_contract_list = function(index, env, all_contracts, cb) {
@ -70,6 +73,26 @@ Deploy.prototype.deploy_contract_list = function(index, env, all_contracts, cb)
} }
} }
Deploy.prototype.deploy_contract_list_synchronously = function(env, all_contracts, cb) {
var _this = this;
all_contracts.forEach(function(className){
_this.deploy_a_contract(env, className, function(){
mark_contract_as_deployed()
});
})
var deployed_contracts_count = 0;
function mark_contract_as_deployed(){
deployed_contracts_count ++;
if(deployed_contracts_count === all_contracts.length)
cb()
}
}
Deploy.prototype.deploy_a_contract = function(env, className, cb) { Deploy.prototype.deploy_a_contract = function(env, className, cb) {
var contractDependencies = this.contractsManager.contractDependencies; var contractDependencies = this.contractsManager.contractDependencies;
var contract = this.contractDB[className]; var contract = this.contractDB[className];