Commit fc2f4843 authored by yann300's avatar yann300

reuse gasestimation

parent 49a15510
...@@ -77,10 +77,13 @@ TxRunner.prototype.execute = function () { ...@@ -77,10 +77,13 @@ TxRunner.prototype.execute = function () {
// we want to be able to run the code in order to debug and find the cause for the failure // we want to be able to run the code in order to debug and find the cause for the failure
// we can't use the blockGasLimit cause the next blocks could have a lower limit : https://github.com/ethereum/remix/issues/506 // we can't use the blockGasLimit cause the next blocks could have a lower limit : https://github.com/ethereum/remix/issues/506
var blockGasLimit = Math.floor(block.gasLimit - (5 * block.gasLimit) / 1024) var blockGasLimit = Math.floor(block.gasLimit - (5 * block.gasLimit) / 1024)
tx.gas = blockGasLimit if (gasEstimation > gasLimit) {
if (tx.gas > gasLimit) { return callback('Gas required exceeds limit: ' + gasLimit)
return callback('Gas required exceeds limit: ' + tx.gas)
} }
if (gasEstimation > blockGasLimit) {
return callback('Gas required exceeds block gas limit: ' + gasLimit)
}
tx.gas = gasEstimation
var sendTransaction = self.personalMode ? self.web3.personal.sendTransaction : self.web3.eth.sendTransaction var sendTransaction = self.personalMode ? self.web3.personal.sendTransaction : self.web3.eth.sendTransaction
sendTransaction(tx, function (err, resp) { sendTransaction(tx, function (err, resp) {
if (err) { if (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment