git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 8666afc1dd3be42258266197d74744366f739564

Rename gasLimit to gasLeft

Alex Beregszaszi committed on 8/23/2016, 12:22:44 AM
Parent: e3569511d2b9077dbe811b4eb5ac6e9defaf7184

Files changed

debugInterface.jschanged
environment.jschanged
interface.jschanged
testEnvironment.jschanged
tests/interface/basic_gas_ops.jsonchanged
tests/interface/default_enviroment.jsonchanged
debugInterface.jsView
@@ -31,9 +31,9 @@
3131 const opcode = opcodes(op)
3232 if (opcode.number) {
3333 opcode.name += opcode.number
3434 }
35- console.error(`op: ${opcode.name} gas: ${this.environment.gasLimit}`)
35+ console.error(`op: ${opcode.name} gas: ${this.environment.gasLeft}`)
3636 console.log('-------------stack--------------')
3737 for (let i = sp; i >= 0; i -= 32) {
3838 console.log(`${(sp - i) / 32} ${this.getMemoryBuffer(i).toString('hex')}`)
3939 }
environment.jsView
@@ -10,9 +10,9 @@
1010 const defaults = {
1111 block: block,
1212 // gas tank
1313 gasPrice: 0,
14- gasLimit: 1000000, // The gas limit for the block
14+ gasLeft: 1000000,
1515 gasRefund: 0,
1616 // call infromation
1717 address: new Address('0x0000000000000000000000000000000000000000'),
1818 origin: new Address('0x0000000000000000000000000000000000000000'),
interface.jsView
@@ -75,9 +75,9 @@
7575 */
7676 getGasLeft () {
7777 this.takeGas(2)
7878
79- return this.environment.gasLimit
79+ return this.environment.gasLeft
8080 }
8181
8282 /**
8383 * Gets address of currently executing account and loads it into memory at
@@ -490,12 +490,12 @@
490490 * Takes gas from the tank. Only needs to check if there's gas left to be taken,
491491 * because every caller of this method is trusted.
492492 */
493493 takeGas (amount) {
494- if (this.environment.gasLimit < amount) {
494+ if (this.environment.gasLeft < amount) {
495495 throw new Error('Ran out of gas')
496496 }
497- this.environment.gasLimit -= amount
497+ this.environment.gasLeft -= amount
498498 }
499499 }
500500
501501 //
testEnvironment.jsView
@@ -48,9 +48,9 @@
4848 if (data.gasPrice) {
4949 self.gasPrice = data.gasPrice
5050 }
5151
52- if (data.gasLimit) {
53- self.gasLimit = data.gasLimit
52+ if (data.gasLeft) {
53+ self.gasLeft = data.gasLeft
5454 }
5555 }
5656 }
tests/interface/basic_gas_ops.jsonView
@@ -1,3 +1,3 @@
11 {
2- "gasLimit": 1000
2+ "gasLeft": 1000
33 }
tests/interface/default_enviroment.jsonView
@@ -1,7 +1,7 @@
11 enviroment: {
22 gasPrice: 0,
3- gasLimit: 0,
3+ gasLeft: 0,
44 address: [],
55 origin: [],
66 coinbase: [],
77 difficulty: [],

Built with git-ssb-web