Commit da7b20096a9e2da5c16128a768e529a9070114a8
Interface: throw error if negative value was given to useGas
Alex Beregszaszi committed on 8/18/2016, 3:43:24 AMParent: f488805c0df12c74d2cb8ed0c5d0e439495676df
Files changed
interface.js | changed |
interface.js | ||
---|---|---|
@@ -60,14 +60,17 @@ | ||
60 | 60 | * Subtracts an amount to the gas counter |
61 | 61 | * @param {integer} amount the amount to subtract to the gas counter |
62 | 62 | */ |
63 | 63 | useGas (amount) { |
64 | - if (amount > 0) { | |
65 | - if (this.environment.gasLimit < amount) { | |
66 | - throw new Error('Ran out of gas') | |
67 | - } | |
68 | - this.environment.gasLimit -= amount | |
64 | + if (amount < 0) { | |
65 | + throw new Error('Negative gas deduction requested') | |
69 | 66 | } |
67 | + | |
68 | + if (this.environment.gasLimit < amount) { | |
69 | + throw new Error('Ran out of gas') | |
70 | + } | |
71 | + | |
72 | + this.environment.gasLimit -= amount | |
70 | 73 | } |
71 | 74 | |
72 | 75 | /** |
73 | 76 | * Returns the current amount of gas |
Built with git-ssb-web