Commit 23e12cd33ecd2ef038fb71cc7b53d43a2dd19637
remove serizliation for metedata
Signed-off-by: wanderer <mjbecze@gmail.com>wanderer committed on 3/1/2018, 1:30:11 AM
Parent: 1ee5f08dcf25af27f0dce6fdc1eab39b185d202f
Files changed
actor.js | changed |
index.js | changed |
tests/index.js | changed |
actor.js | ||
---|---|---|
@@ -16,24 +16,13 @@ | ||
16 | 16 | this.running = false |
17 | 17 | this.container = new this.Container(this) |
18 | 18 | } |
19 | 19 | |
20 | - serializeMetaData () { | |
21 | - return Actor.serializeMetaData(this.type, this.nonce) | |
22 | - } | |
23 | - | |
24 | - getFuncRef (name) { | |
25 | - return { | |
26 | - name, | |
27 | - destId: this.id | |
28 | - } | |
29 | - } | |
30 | - | |
31 | 20 | /** |
32 | 21 | * Runs the shutdown routine for the actor |
33 | 22 | */ |
34 | 23 | async shutdown () { |
35 | - await this.tree.set(this.id.id, this.serializeMetaData()) | |
24 | + await this.tree.set(this.id.id, [this.type, this.nonce]) | |
36 | 25 | if (this.storage.length) { |
37 | 26 | const state = await this.tree.get(this.id.id) |
38 | 27 | return this.tree.graph.set(state.root, '2', this.storage) |
39 | 28 | } |
@@ -103,16 +92,5 @@ | ||
103 | 92 | message._fromId = this.id |
104 | 93 | |
105 | 94 | this.hypervisor.scheduler.queue([message]) |
106 | 95 | } |
107 | - | |
108 | - static serializeMetaData (type, nonce = 0) { | |
109 | - return [type, nonce] | |
110 | - } | |
111 | - | |
112 | - static deserializeMetaData ([type, nonce]) { | |
113 | - return { | |
114 | - nonce, | |
115 | - type | |
116 | - } | |
117 | - } | |
118 | 96 | } |
index.js | ||
---|---|---|
@@ -1,6 +1,5 @@ | ||
1 | 1 | const Actor = require('./actor.js') |
2 | -const RadixTree = require('dfinity-radix-tree') | |
3 | 2 | const Scheduler = require('./scheduler.js') |
4 | 3 | const {ID} = require('./systemObjects.js') |
5 | 4 | |
6 | 5 | module.exports = class Hypervisor { |
@@ -32,9 +31,9 @@ | ||
32 | 31 | async loadActor (id) { |
33 | 32 | const state = await this.tree.get(id.id, true) |
34 | 33 | let code = await this.tree.graph.get(state.root, '1') |
35 | 34 | let storage = await this.tree.graph.get(state.root, '2') |
36 | - const {type, nonce} = Actor.deserializeMetaData(state.value) | |
35 | + const [type, nonce] = state.value | |
37 | 36 | const Container = this._containerTypes[type] |
38 | 37 | |
39 | 38 | // create a new actor instance |
40 | 39 | const actor = new Actor({ |
@@ -65,9 +64,9 @@ | ||
65 | 64 | const encoded = encodedID(id) |
66 | 65 | let idHash = await this._getHashFromObj(encoded) |
67 | 66 | idHash = new ID(idHash) |
68 | 67 | const module = await Container.onCreation(code, idHash, this.tree) |
69 | - const metaData = Actor.serializeMetaData(type) | |
68 | + const metaData = [type, 0] | |
70 | 69 | |
71 | 70 | // save the container in the state |
72 | 71 | this.tree.set(idHash.id, metaData) |
73 | 72 | if (code) { |
tests/index.js | ||
---|---|---|
@@ -280,9 +280,12 @@ | ||
280 | 280 | async start (funcRef) { |
281 | 281 | const {module} = await this.actor.createActor(testVMContainerB.typeId) |
282 | 282 | const message = new Message({ |
283 | 283 | funcRef: module.main, |
284 | - funcArguments: [this.actor.getFuncRef('main')] | |
284 | + funcArguments: [{ | |
285 | + name: 'main', | |
286 | + destId: this.actor.id | |
287 | + }] | |
285 | 288 | }) |
286 | 289 | this.actor.send(message) |
287 | 290 | } |
288 | 291 | main (data) { |
Built with git-ssb-web