git ssb

0+

wanderer🌟 / js-primea-hypervisor



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.jschanged
index.jschanged
tests/index.jschanged
actor.jsView
@@ -16,24 +16,13 @@
1616 this.running = false
1717 this.container = new this.Container(this)
1818 }
1919
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-
3120 /**
3221 * Runs the shutdown routine for the actor
3322 */
3423 async shutdown () {
35- await this.tree.set(this.id.id, this.serializeMetaData())
24+ await this.tree.set(this.id.id, [this.type, this.nonce])
3625 if (this.storage.length) {
3726 const state = await this.tree.get(this.id.id)
3827 return this.tree.graph.set(state.root, '2', this.storage)
3928 }
@@ -103,16 +92,5 @@
10392 message._fromId = this.id
10493
10594 this.hypervisor.scheduler.queue([message])
10695 }
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- }
11896 }
index.jsView
@@ -1,6 +1,5 @@
11 const Actor = require('./actor.js')
2-const RadixTree = require('dfinity-radix-tree')
32 const Scheduler = require('./scheduler.js')
43 const {ID} = require('./systemObjects.js')
54
65 module.exports = class Hypervisor {
@@ -32,9 +31,9 @@
3231 async loadActor (id) {
3332 const state = await this.tree.get(id.id, true)
3433 let code = await this.tree.graph.get(state.root, '1')
3534 let storage = await this.tree.graph.get(state.root, '2')
36- const {type, nonce} = Actor.deserializeMetaData(state.value)
35+ const [type, nonce] = state.value
3736 const Container = this._containerTypes[type]
3837
3938 // create a new actor instance
4039 const actor = new Actor({
@@ -65,9 +64,9 @@
6564 const encoded = encodedID(id)
6665 let idHash = await this._getHashFromObj(encoded)
6766 idHash = new ID(idHash)
6867 const module = await Container.onCreation(code, idHash, this.tree)
69- const metaData = Actor.serializeMetaData(type)
68+ const metaData = [type, 0]
7069
7170 // save the container in the state
7271 this.tree.set(idHash.id, metaData)
7372 if (code) {
tests/index.jsView
@@ -280,9 +280,12 @@
280280 async start (funcRef) {
281281 const {module} = await this.actor.createActor(testVMContainerB.typeId)
282282 const message = new Message({
283283 funcRef: module.main,
284- funcArguments: [this.actor.getFuncRef('main')]
284+ funcArguments: [{
285+ name: 'main',
286+ destId: this.actor.id
287+ }]
285288 })
286289 this.actor.send(message)
287290 }
288291 main (data) {

Built with git-ssb-web