Commit c6e879cecacacc8ce87b4741f02493827fd992c8
Kernel: assume every address is an instance of Address
Alex Beregszaszi committed on 8/23/2016, 12:27:46 AMParent: 07abd8f821130e425de30cfb326a51dc64c4bf91
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -20,8 +20,9 @@ | ||
20 | 20 | const Environment = require('./environment.js') |
21 | 21 | |
22 | 22 | const DebugInterface = require('./debugInterface.js') |
23 | 23 | |
24 | +const Address = require('./address.js') | |
24 | 25 | const Utils = require('./utils.js') |
25 | 26 | |
26 | 27 | module.exports = class Kernel { |
27 | 28 | // runs some code in the VM |
@@ -67,13 +68,13 @@ | ||
67 | 68 | if (address === 0) { |
68 | 69 | if (data) { |
69 | 70 | let codeHash = sha3(data) |
70 | 71 | this.environment.state.set(codeHash, data); |
71 | - this.environment.state.set(new Uint8Array(address).toString(), { balance: value, codeHash: codeHash }) | |
72 | + this.environment.state.set(address.toString(), { balance: value, codeHash: codeHash }) | |
72 | 73 | } |
73 | 74 | } |
74 | 75 | |
75 | - var account = this.environment.state.get(new Uint8Array(address).toString()) | |
76 | + let account = this.environment.state.get(address.toString()) | |
76 | 77 | if (!account) { |
77 | 78 | throw new Error('Account not found') |
78 | 79 | } |
79 | 80 | |
@@ -128,9 +129,9 @@ | ||
128 | 129 | // { balance, codeHash, stateRoot } |
129 | 130 | // |
130 | 131 | |
131 | 132 | // look up sender |
132 | - let fromAccount = this.environment.state.get(new Uint8Array(tx.form).toString()) | |
133 | + let fromAccount = this.environment.state.get(tx.from.toString()) | |
133 | 134 | if (!fromAccount) { |
134 | 135 | throw new Error('Sender account not found') |
135 | 136 | } |
136 | 137 |
Built with git-ssb-web