Files: 48df42c8ab634c0d9fc7597e52106352878124fa / hypervisor.js
806 bytesRaw
1 | const Kernel = require('./index.js') |
2 | const Vertex = require('merkle-trie') |
3 | const Block = require('./deps/block.js') |
4 | const blockchain = require('./fakeBlockChain.js') |
5 | const codeHandlers = require('./codeHandler.js') |
6 | |
7 | module.exports = class Hypervisor { |
8 | constructor (state = new Vertex()) { |
9 | this.state = state |
10 | if (state.isEmpty) { |
11 | state.set('block', new Vertex({ |
12 | value: new Block() |
13 | })) |
14 | state.set('blockchain', new Vertex({ |
15 | value: blockchain |
16 | })) |
17 | } |
18 | this.root = new Kernel({ |
19 | state: state |
20 | }) |
21 | } |
22 | |
23 | set (path, kernel) { |
24 | this.state.set(path, new Vertex({ |
25 | value: kernel |
26 | })) |
27 | } |
28 | |
29 | send (message) { |
30 | this.root.send(message) |
31 | return message.result() |
32 | } |
33 | |
34 | addVM (type, handler) { |
35 | codeHandlers.handlers.type = handler |
36 | } |
37 | } |
38 |
Built with git-ssb-web