git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit da7b20096a9e2da5c16128a768e529a9070114a8

Interface: throw error if negative value was given to useGas

Alex Beregszaszi committed on 8/18/2016, 3:43:24 AM
Parent: f488805c0df12c74d2cb8ed0c5d0e439495676df

Files changed

interface.jschanged
interface.jsView
@@ -60,14 +60,17 @@
6060 * Subtracts an amount to the gas counter
6161 * @param {integer} amount the amount to subtract to the gas counter
6262 */
6363 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')
6966 }
67+
68+ if (this.environment.gasLimit < amount) {
69+ throw new Error('Ran out of gas')
70+ }
71+
72+ this.environment.gasLimit -= amount
7073 }
7174
7275 /**
7376 * Returns the current amount of gas

Built with git-ssb-web