diff options
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/cryptoDispatcher.ts | 7 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/headless/helpers.ts | 9 |
2 files changed, 13 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoDispatcher.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoDispatcher.ts index 85f9acddc..1c0d509e6 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoDispatcher.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoDispatcher.ts @@ -15,7 +15,8 @@ */ /** - * API to access the Taler crypto worker thread. + * API to access the Taler crypto worker. + * * @author Florian Dold */ @@ -76,6 +77,10 @@ interface WorkItem { */ const NUM_PRIO = 5; +/** + * A crypto worker factory is responsible for creating new + * crypto workers on-demand. + */ export interface CryptoWorkerFactory { /** * Start a new worker. diff --git a/packages/taler-wallet-core/src/headless/helpers.ts b/packages/taler-wallet-core/src/headless/helpers.ts index 63967d4ad..2be9be9a1 100644 --- a/packages/taler-wallet-core/src/headless/helpers.ts +++ b/packages/taler-wallet-core/src/headless/helpers.ts @@ -61,6 +61,8 @@ export interface DefaultNodeWalletArgs { * of the default one. */ httpLib?: HttpRequestLibrary; + + cryptoWorkerType?: "sync" | "node-worker-thread"; } /** @@ -160,10 +162,11 @@ export async function getDefaultNodeWallet2( const myDb = await openTalerDatabase(myIdbFactory, myVersionChange); let workerFactory; - if (process.env["TALER_WALLET_SYNC_CRYPTO"]) { + const cryptoWorkerType = args.cryptoWorkerType ?? "node-worker-thread"; + if (cryptoWorkerType === "sync") { logger.info("using synchronous crypto worker"); workerFactory = new SynchronousCryptoWorkerFactory(); - } else { + } else if (cryptoWorkerType === "node-worker-thread") { try { // Try if we have worker threads available, fails in older node versions. const _r = "require"; @@ -177,6 +180,8 @@ export async function getDefaultNodeWallet2( ); workerFactory = new SynchronousCryptoWorkerFactory(); } + } else { + throw Error(`unsupported crypto worker type '${cryptoWorkerType}'`); } const timer = new SetTimeoutTimerAPI(); |