Commit 7250d1d613c9fe437b5c03af7ff4973d93dd5227
renamed addGas -> useGas
wanderer committed on 7/17/2016, 3:05:57 PMParent: 81bc698eafe0e2013602fe8f6e9aae6fe7b0ee7b
Files changed
environment.js | changed |
interface.js | changed |
environment.js | ||
---|---|---|
@@ -5,9 +5,8 @@ | ||
5 | 5 | constructor (data) { |
6 | 6 | const defaults = { |
7 | 7 | // gas tank |
8 | 8 | gasCounter: 0, // TODO: gasCounter is only 53 bits |
9 | - gas: 0, // The amount of gas this contract has | |
10 | 9 | gasPrice: 0, |
11 | 10 | gasLimit: 0, // The gas limit for the block |
12 | 11 | // call infromation |
13 | 12 | address: new Uint8Array(20), |
@@ -29,13 +28,14 @@ | ||
29 | 28 | this.state = new Graph() |
30 | 29 | |
31 | 30 | if (data) { |
32 | 31 | data = JSON.parse(data) |
33 | - Object.assign(this, defaults, data) | |
34 | 32 | } else { |
35 | 33 | data = {} |
36 | 34 | } |
37 | 35 | |
36 | + Object.assign(this, defaults, data) | |
37 | + | |
38 | 38 | if (data.accounts) { |
39 | 39 | this.accounts = new Graph() |
40 | 40 | const self = this |
41 | 41 | data.accounts.forEach((account) => { |
interface.js | ||
---|---|---|
@@ -31,9 +31,9 @@ | ||
31 | 31 | /** |
32 | 32 | * Subtracts an amount to the gas counter |
33 | 33 | * @param {integer} amount the amount to subtract to the gas counter |
34 | 34 | */ |
35 | - addGas (amount) { | |
35 | + useGas (amount) { | |
36 | 36 | if (amount > 0) { |
37 | 37 | ENV.gasCounter += amount |
38 | 38 | } |
39 | 39 | } |
@@ -50,9 +50,9 @@ | ||
50 | 50 | * Returns the current gasCounter |
51 | 51 | * @return {integer} |
52 | 52 | */ |
53 | 53 | gasLeft () { |
54 | - return ENV.gas - ENV.gasCounter | |
54 | + return ENV.gasLimit - ENV.gasCounter | |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Gets address of currently executing account and loads it into memory at |
Built with git-ssb-web