Skip to content

Commit

Permalink
remove chache
Browse files Browse the repository at this point in the history
  • Loading branch information
wanderer committed Mar 12, 2018
1 parent 4764e10 commit 8aa474d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 34 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ module.exports = class Hypervisor {
type,
code,
storage: storage || [],
cachedb: this.tree.dag._dag,
tree: this.tree
})

Expand Down
37 changes: 4 additions & 33 deletions wasmContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,7 @@ module.exports = class WasmContainer {
}

static async onCreation (unverifiedWasm, id, tree) {
const cachedb = tree.dag._dag
let {json, wasm, modRef} = this.createModule(unverifiedWasm, id)
await Promise.all([
new Promise((resolve, reject) => {
cachedb.put(id.id.toString() + 'meta', JSON.stringify(json), resolve)
}),
new Promise((resolve, reject) => {
cachedb.put(id.id.toString() + 'code', wasm.toString('hex'), resolve)
})
])
let {modRef} = this.createModule(unverifiedWasm, id)
return modRef
}

Expand Down Expand Up @@ -297,31 +288,11 @@ module.exports = class WasmContainer {
}

async onStartup () {
let [json, wasm] = await Promise.all([
new Promise((resolve, reject) => {
this.actor.cachedb.get(this.actor.id.id.toString() + 'meta', (err, json) => {
if (err) {
reject(err)
} else {
resolve(json)
}
})
}),
new Promise((resolve, reject) => {
this.actor.cachedb.get(this.actor.id.id.toString() + 'code', (err, wasm) => {
if (err) {
reject(err)
} else {
resolve(wasm)
}
})
})
])
wasm = Buffer.from(wasm, 'hex')
json = JSON.parse(json)
const code = this.actor.code
const {json, wasm, modRef} = WasmContainer.createModule(code, this.actor.id)
this.mod = WebAssembly.Module(wasm)
this.json = json
this.modSelf = ModuleRef.fromMetaJSON(json, this.actor.id)
this.modSelf = modRef
}

get8Memory (offset, length) {
Expand Down

0 comments on commit 8aa474d

Please sign in to comment.