git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: 48df42c8ab634c0d9fc7597e52106352878124fa

Files: 48df42c8ab634c0d9fc7597e52106352878124fa / hypervisor.js

806 bytesRaw
1const Kernel = require('./index.js')
2const Vertex = require('merkle-trie')
3const Block = require('./deps/block.js')
4const blockchain = require('./fakeBlockChain.js')
5const codeHandlers = require('./codeHandler.js')
6
7module.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