[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-wallet-webex] 04/05: load wasm binary for akono
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-wallet-webex] 04/05: load wasm binary for akono |
Date: |
Fri, 16 Aug 2019 15:04:05 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-webex.
commit 8f5b6ffd7d02986176c95c8800a8292555e2702b
Author: Florian Dold <address@hidden>
AuthorDate: Fri Aug 16 10:31:36 2019 +0200
load wasm binary for akono
---
src/crypto/synchronousWorker.ts | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/src/crypto/synchronousWorker.ts b/src/crypto/synchronousWorker.ts
index 1c98209a..7d115f1d 100644
--- a/src/crypto/synchronousWorker.ts
+++ b/src/crypto/synchronousWorker.ts
@@ -57,22 +57,39 @@ export class SynchronousCryptoWorker {
}
}
- private getEmscriptenEnvironment(): Promise<EmscEnvironment> {
+ private async getWasmBinary(): Promise<Uint8Array> {
+ // @ts-ignore
+ const akonoGetData = global.__akono_getData;
+ if (akonoGetData) {
+ // We're running embedded node on Android
+ console.log("reading wasm binary from akono");
+ const data = akonoGetData("taler-emscripten-lib.wasm");
+ // The data we get is base64-encoded binary data
+ let buf = new Buffer(data, 'base64');
+ return new Uint8Array(buf);
+
+ } else {
+ // We're in a normal node environment
+ const binaryPath = __dirname +
"/../../../emscripten/taler-emscripten-lib.wasm";
+ console.log("reading from", binaryPath);
+ const wasmBinary = new Uint8Array(fs.readFileSync(binaryPath));
+ return wasmBinary;
+ }
+ }
+
+ private async getEmscriptenEnvironment(): Promise<EmscEnvironment> {
if (this.cachedEmscEnvironment) {
- return Promise.resolve(this.cachedEmscEnvironment);
+ return this.cachedEmscEnvironment;
}
if (this.cachedEmscEnvironmentPromise) {
return this.cachedEmscEnvironmentPromise;
}
- const binaryPath =
- __dirname + "/../../../emscripten/taler-emscripten-lib.wasm";
- console.log("reading from", binaryPath);
- const wasmBinary = new Uint8Array(fs.readFileSync(binaryPath));
-
let lib: any;
+ const wasmBinary = await this.getWasmBinary();
+
return new Promise((resolve, reject) => {
// Arguments passed to the emscripten prelude
const libArgs = {
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [taler-wallet-webex] branch master updated (ea2fb677 -> a1e0fc3b), gnunet, 2019/08/16
- [GNUnet-SVN] [taler-wallet-webex] 01/05: load wasm manually from correct location, gnunet, 2019/08/16
- [GNUnet-SVN] [taler-wallet-webex] 04/05: load wasm binary for akono,
gnunet <=
- [GNUnet-SVN] [taler-wallet-webex] 03/05: emscripten env consistency, gnunet, 2019/08/16
- [GNUnet-SVN] [taler-wallet-webex] 02/05: oops, actually pass arguments to emscripten, gnunet, 2019/08/16
- [GNUnet-SVN] [taler-wallet-webex] 05/05: crypto worker refactoring, gnunet, 2019/08/16