diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index d2110ed2..30514f33 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -54,7 +54,9 @@ BlockchainConfig.prototype.config = function(env) { whisper: config.whisper || false, account: config.account, 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; diff --git a/lib/deploy.js b/lib/deploy.js index 11ee3a9e..d5d2db29 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -54,7 +54,10 @@ Deploy.prototype.deploy_contracts = function(env, cb) { this.contractDB = this.contractsManager.contractDB; 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) { @@ -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) { var contractDependencies = this.contractsManager.contractDependencies; var contract = this.contractDB[className];