git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 8aa474dcde21c44a2049cae1deeb33baa977dad8

remove chache

wanderer committed on 3/12/2018, 5:58:21 PM
Parent: 4764e106f64da9641c4d72e1e6974d46024fbab3

Files changed

index.jschanged
wasmContainer.jschanged
index.jsView
@@ -47,9 +47,8 @@
4747 nonce,
4848 type,
4949 code,
5050 storage: storage || [],
51- cachedb: this.tree.dag._dag,
5251 tree: this.tree
5352 })
5453
5554 await actor.startup()
wasmContainer.jsView
@@ -88,18 +88,9 @@
8888 }
8989 }
9090
9191 static async onCreation (unverifiedWasm, id, tree) {
92- const cachedb = tree.dag._dag
93- let {json, wasm, modRef} = this.createModule(unverifiedWasm, id)
94- await Promise.all([
95- new Promise((resolve, reject) => {
96- cachedb.put(id.id.toString() + 'meta', JSON.stringify(json), resolve)
97- }),
98- new Promise((resolve, reject) => {
99- cachedb.put(id.id.toString() + 'code', wasm.toString('hex'), resolve)
100- })
101- ])
92+ let {modRef} = this.createModule(unverifiedWasm, id)
10293 return modRef
10394 }
10495
10596 getInterface (funcRef) {
@@ -296,33 +287,13 @@
296287 return this._opsQueue
297288 }
298289
299290 async onStartup () {
300- let [json, wasm] = await Promise.all([
301- new Promise((resolve, reject) => {
302- this.actor.cachedb.get(this.actor.id.id.toString() + 'meta', (err, json) => {
303- if (err) {
304- reject(err)
305- } else {
306- resolve(json)
307- }
308- })
309- }),
310- new Promise((resolve, reject) => {
311- this.actor.cachedb.get(this.actor.id.id.toString() + 'code', (err, wasm) => {
312- if (err) {
313- reject(err)
314- } else {
315- resolve(wasm)
316- }
317- })
318- })
319- ])
320- wasm = Buffer.from(wasm, 'hex')
321- json = JSON.parse(json)
291+ const code = this.actor.code
292+ const {json, wasm, modRef} = WasmContainer.createModule(code, this.actor.id)
322293 this.mod = WebAssembly.Module(wasm)
323294 this.json = json
324- this.modSelf = ModuleRef.fromMetaJSON(json, this.actor.id)
295+ this.modSelf = modRef
325296 }
326297
327298 get8Memory (offset, length) {
328299 return new Uint8Array(this.instance.exports.memory.buffer, offset, length)

Built with git-ssb-web