gnunet-svn
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]