index.jsView |
---|
1 | 1 | const Actor = require('./actor.js') |
2 | 2 | const Scheduler = require('./scheduler.js') |
| 3 | +const leb128 = require('leb128').unsigned |
3 | 4 | |
4 | 5 | module.exports = class Hypervisor { |
5 | 6 | |
6 | 7 | * The Hypervisor manages the container instances by instantiating them and |
28 | 29 | |
29 | 30 | |
30 | 31 | async _loadActor (id) { |
31 | 32 | const state = await this.tree.getSubTree(id) |
32 | | - const container = this._containerTypes[state.root['/'][3][0]] |
| 33 | + const type = leb128.decode(state.root['/'][3]) |
| 34 | + const container = this._containerTypes[type] |
33 | 35 | |
34 | 36 | |
35 | 37 | const actor = new Actor({ |
36 | 38 | hypervisor: this, |
70 | 72 | */ |
71 | 73 | async createActor (type, message, id = {nonce: this.nonce++, parent: null}) { |
72 | 74 | const encoded = encodedID(id) |
73 | 75 | const idHash = await this._getHashFromObj(encoded) |
74 | | - const state = Buffer.from([type, 0, 0]) |
| 76 | + const state = Buffer.concat([leb128.encode(type), Buffer.from([0, 0])]) |
75 | 77 | |
76 | 78 | |
77 | 79 | this.tree.set(idHash, state) |
78 | 80 | |