Skip to content

Commit

Permalink
Cleanup startup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Jul 2, 2018
1 parent d64ba74 commit 83790f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/client-wasm/src/create/index.ts
Expand Up @@ -31,16 +31,16 @@ export default function wasm ({ config: { wasm: { heapSize = defaults.HEAP_SIZE_
const env = instrument('runtime', elapsed, (): WasmInstanceExports =>
createEnv(runtime, createMemory(0, 0))
);
const proxy = instrument('chain', elapsed, (): WasmInstanceExports =>
const chain = instrument('chain', elapsed, (): WasmInstanceExports =>
createExports(chainCode, { env })
);
const instance = instrument('proxy', elapsed, (): WasmInstanceExports =>
createExports(chainProxy, { proxy }, createMemory(0, 0))
createExports(chainProxy, { proxy: chain }, createMemory(0, 0))
);

const offset = proxy.memory.grow(Math.ceil(heapSize / 64));
const offset = chain.memory.grow(Math.ceil(heapSize / 64));

runtime.environment.heap.setWasmMemory(proxy.memory, offset * 64 * 1024);
runtime.environment.heap.setWasmMemory(chain.memory, offset * 64 * 1024);

l.debug(() => `WASM created ${elapsed.join(', ')}`);

Expand Down
15 changes: 11 additions & 4 deletions packages/client/scripts/polkadot.js
Expand Up @@ -3,9 +3,16 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.

try {
require('../index');
} catch (error) {
const fs = require('fs');
const path = require('path');

const [compiled] = ['../index.js']
.map((file) => path.join(__dirname, file))
.filter((file) => fs.existsSync(file));

if (compiled) {
require(compiled);
} else {
require('@babel/register')({
extensions: ['.js', '.ts'],
plugins: [
Expand All @@ -16,5 +23,5 @@ try {
}]
]
});
require('../src');
require('../src/index.ts');
}

0 comments on commit 83790f4

Please sign in to comment.