Files: fc6f0a0f0855a69b0137cdf8dd265e6e2fb4e16f / index.js
1495 bytesRaw
1 | /** |
2 | * This implements the Ethereum Kernel |
3 | * The kernal handles the following |
4 | * - Interprocess communications |
5 | * - Intializing the VM and exposes ROM to it (codeHandler) |
6 | * - Expose namespace which VM instance exists and Intializes the Environment (callHandler) |
7 | * - Provides some built in contract (runTx, runBlock) |
8 | * - Provides resource sharing and limiting via gas |
9 | * |
10 | * All State should be stored in the Environment. |
11 | */ |
12 | // const Environment = require('./environment.js') |
13 | const Interface = require('./interface.js') |
14 | |
15 | module.exports = class Kernal { |
16 | // runs some code in the VM |
17 | constructor (nameState) { |
18 | this.state = nameState |
19 | } |
20 | |
21 | // handles running code. `code` can be seen as ROM here |
22 | static codeHandler (code, environment) { |
23 | const ethInterface = new Interface(environment) |
24 | const instance = Wasm.instantiateModule(code, ethInterface) |
25 | ethInterface.setModule(ethInterface) |
26 | return instance |
27 | } |
28 | |
29 | // loads code from the merkle trie and delegates the message |
30 | static call (path, data, environment) { |
31 | // const instance = Wasm.instantiateModule(code, interface) |
32 | // interface.setModule(instance) |
33 | // return instance |
34 | } |
35 | |
36 | // run tx |
37 | runTx (tx, environment) { |
38 | // verify tx then send to call Handler |
39 | this.call(tx, environment) |
40 | } |
41 | |
42 | // run block |
43 | runBlock (block, environment) { |
44 | // verify block then run each tx |
45 | block.tx.forEach((tx) => { |
46 | this.runTx(tx, environment) |
47 | }) |
48 | |
49 | } |
50 | |
51 | // run blockchain |
52 | // runBlockchain () {} |
53 | } |
54 |
Built with git-ssb-web