fix gas settings; add information of gas used with deployment

This commit is contained in:
Iuri Matias 2016-10-22 09:42:52 -04:00
parent d05cf90b5b
commit ae3bcb1060
2 changed files with 11 additions and 6 deletions

View File

@ -42,20 +42,24 @@ ContractsManager.prototype.build = function() {
contract.gasEstimates = compiledContract.gasEstimates; contract.gasEstimates = compiledContract.gasEstimates;
contract.functionHashes = compiledContract.functionHashes; contract.functionHashes = compiledContract.functionHashes;
contract.abiDefinition = compiledContract.abiDefinition; contract.abiDefinition = compiledContract.abiDefinition;
contract.gas = (contractConfig && contractConfig.gas) || this.contractsConfig.gas;
if (this.contractsConfig.gas === 'auto') { if (contract.deploy === undefined) {
contract.deploy = true;
}
if (contract.gas === 'auto') {
var maxGas; var maxGas;
if (contract.deploy) { if (contract.deploy) {
maxGas = Math.max(contract.gasEstimates.creation[0], contract.gasEstimates.creation[1], 500000); maxGas = Math.max(contract.gasEstimates.creation[0], contract.gasEstimates.creation[1], 500000);
} else { } else {
maxGas = 500000; maxGas = 500000;
} }
var adjustedGas = Math.round(maxGas * 1.01); // TODO: put a check so it doesn't go over the block limit
var adjustedGas = Math.round(maxGas * 1.40);
contract.gas = adjustedGas; contract.gas = adjustedGas;
} else {
contract.gas = this.contractsConfig.gas;
} }
contract.gasPrice = this.contractsConfig.gasPrice; contract.gasPrice = contract.gasPrice || this.contractsConfig.gasPrice;
contract.type = 'file'; contract.type = 'file';
contract.className = className; contract.className = className;

View File

@ -117,7 +117,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
gasPrice: contract.gasPrice gasPrice: contract.gasPrice
}); });
self.logger.info("deploying " + contract.className); self.logger.info("deploying " + contract.className + " with " + contract.gas + " gas");
contractParams.push(function(err, transaction) { contractParams.push(function(err, transaction) {
self.logger.contractsState(self.contractsManager.contractsState()); self.logger.contractsState(self.contractsManager.contractsState());
@ -129,6 +129,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
} else if (transaction.address !== undefined) { } else if (transaction.address !== undefined) {
self.logger.info(contract.className + " deployed at " + transaction.address); self.logger.info(contract.className + " deployed at " + transaction.address);
contract.deployedAddress = transaction.address; contract.deployedAddress = transaction.address;
contract.transactionHash = transaction.transactionHash;
callback(null, transaction.address); callback(null, transaction.address);
} }
}); });