diff options
author | Florian Dold <florian@dold.me> | 2022-11-10 13:54:39 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-11-10 13:54:39 +0100 |
commit | 344b4f62a22fb8afe910f809b04485b10b51a79b (patch) | |
tree | cfa9b5cadb5a2d81be8c6d16449446646ec688d3 /packages/taler-wallet-core | |
parent | b65bb1af356e353051aa376ccb751476e7aa6e01 (diff) | |
download | wallet-core-344b4f62a22fb8afe910f809b04485b10b51a79b.tar.xz |
quickjs preparations, clearer worker(-factory) names
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactoryNode.ts (renamed from packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactory.ts) | 6 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactoryPlain.ts | 36 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/synchronousWorkerNode.ts | 2 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/synchronousWorkerPlain.ts (renamed from packages/taler-wallet-core/src/crypto/workers/synchronousWorkerWeb.ts) | 2 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/headless/helpers.ts | 6 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/index.browser.ts | 2 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/index.node.ts | 4 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/index.ts | 2 |
8 files changed, 49 insertions, 11 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactory.ts b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactoryNode.ts index e9d67eec6..46cf12915 100644 --- a/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactory.ts +++ b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactoryNode.ts @@ -19,15 +19,15 @@ */ import { CryptoWorkerFactory } from "./cryptoDispatcher.js"; import { CryptoWorker } from "./cryptoWorkerInterface.js"; -import { SynchronousCryptoWorker } from "./synchronousWorkerNode.js"; +import { SynchronousCryptoWorkerNode } from "./synchronousWorkerNode.js"; /** * The synchronous crypto worker produced by this factory doesn't run in the * background, but actually blocks the caller until the operation is done. */ -export class SynchronousCryptoWorkerFactory implements CryptoWorkerFactory { +export class SynchronousCryptoWorkerFactoryNode implements CryptoWorkerFactory { startWorker(): CryptoWorker { - return new SynchronousCryptoWorker(); + return new SynchronousCryptoWorkerNode(); } getConcurrency(): number { diff --git a/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactoryPlain.ts b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactoryPlain.ts new file mode 100644 index 000000000..7662b41f5 --- /dev/null +++ b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerFactoryPlain.ts @@ -0,0 +1,36 @@ +/* + This file is part of GNU Taler + (C) 2019 GNUnet e.V. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** + * Imports. + */ +import { CryptoWorkerFactory } from "./cryptoDispatcher.js"; +import { CryptoWorker } from "./cryptoWorkerInterface.js"; +import { SynchronousCryptoWorkerPlain } from "./synchronousWorkerPlain.js"; + +/** + * The synchronous crypto worker produced by this factory doesn't run in the + * background, but actually blocks the caller until the operation is done. + */ +export class SynchronousCryptoWorkerFactoryPlain implements CryptoWorkerFactory { + startWorker(): CryptoWorker { + return new SynchronousCryptoWorkerPlain(); + } + + getConcurrency(): number { + return 1; + } +} diff --git a/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerNode.ts b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerNode.ts index 1f83dc519..b2653158c 100644 --- a/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerNode.ts +++ b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerNode.ts @@ -31,7 +31,7 @@ const logger = new Logger("synchronousWorker.ts"); * The node crypto worker can also use IPC to offload cryptographic * operations to a helper process (usually written in C / part of taler-exchange). */ -export class SynchronousCryptoWorker implements CryptoWorker { +export class SynchronousCryptoWorkerNode implements CryptoWorker { /** * Function to be called when we receive a message from the worker thread. */ diff --git a/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerWeb.ts b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerPlain.ts index 0ba365fa1..058896828 100644 --- a/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerWeb.ts +++ b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerPlain.ts @@ -31,7 +31,7 @@ const logger = new Logger("synchronousWorker.ts"); * Worker implementation that synchronously executes cryptographic * operations. */ -export class SynchronousCryptoWorker implements CryptoWorker { +export class SynchronousCryptoWorkerPlain implements CryptoWorker { /** * Function to be called when we receive a message from the worker thread. */ diff --git a/packages/taler-wallet-core/src/headless/helpers.ts b/packages/taler-wallet-core/src/headless/helpers.ts index cef7c94d9..64edf8fb0 100644 --- a/packages/taler-wallet-core/src/headless/helpers.ts +++ b/packages/taler-wallet-core/src/headless/helpers.ts @@ -33,7 +33,7 @@ import { AccessStats } from "@gnu-taler/idb-bridge"; import { Logger, WalletNotification } from "@gnu-taler/taler-util"; import * as fs from "fs"; import { NodeThreadCryptoWorkerFactory } from "../crypto/workers/nodeThreadWorker.js"; -import { SynchronousCryptoWorkerFactory } from "../crypto/workers/synchronousWorkerFactory.js"; +import { SynchronousCryptoWorkerFactoryNode } from "../crypto/workers/synchronousWorkerFactoryNode.js"; import { openTalerDatabase } from "../db-utils.js"; import { HttpRequestLibrary } from "../util/http.js"; import { SetTimeoutTimerAPI } from "../util/timer.js"; @@ -165,7 +165,7 @@ export async function getDefaultNodeWallet2( const cryptoWorkerType = args.cryptoWorkerType ?? "node-worker-thread"; if (cryptoWorkerType === "sync") { logger.info("using synchronous crypto worker"); - workerFactory = new SynchronousCryptoWorkerFactory(); + workerFactory = new SynchronousCryptoWorkerFactoryNode(); } else if (cryptoWorkerType === "node-worker-thread") { try { // Try if we have worker threads available, fails in older node versions. @@ -179,7 +179,7 @@ export async function getDefaultNodeWallet2( logger.warn( "worker threads not available, falling back to synchronous workers", ); - workerFactory = new SynchronousCryptoWorkerFactory(); + workerFactory = new SynchronousCryptoWorkerFactoryNode(); } } else { throw Error(`unsupported crypto worker type '${cryptoWorkerType}'`); diff --git a/packages/taler-wallet-core/src/index.browser.ts b/packages/taler-wallet-core/src/index.browser.ts index 029bc533f..02d3665c2 100644 --- a/packages/taler-wallet-core/src/index.browser.ts +++ b/packages/taler-wallet-core/src/index.browser.ts @@ -15,4 +15,4 @@ */ export * from "./index.js"; -export { SynchronousCryptoWorker } from "./crypto/workers/synchronousWorkerWeb.js"; +export { SynchronousCryptoWorkerPlain as SynchronousCryptoWorker } from "./crypto/workers/synchronousWorkerPlain.js"; diff --git a/packages/taler-wallet-core/src/index.node.ts b/packages/taler-wallet-core/src/index.node.ts index d7211b4dc..8567d13ac 100644 --- a/packages/taler-wallet-core/src/index.node.ts +++ b/packages/taler-wallet-core/src/index.node.ts @@ -24,7 +24,7 @@ export { DefaultNodeWalletArgs, } from "./headless/helpers.js"; export * from "./crypto/workers/nodeThreadWorker.js"; -export { SynchronousCryptoWorker } from "./crypto/workers/synchronousWorkerNode.js"; +export { SynchronousCryptoWorkerNode as SynchronousCryptoWorker } from "./crypto/workers/synchronousWorkerNode.js"; export type { AccessStats } from "@gnu-taler/idb-bridge"; -export * from "./crypto/workers/synchronousWorkerFactory.js"; +export * from "./crypto/workers/synchronousWorkerFactoryNode.js"; diff --git a/packages/taler-wallet-core/src/index.ts b/packages/taler-wallet-core/src/index.ts index afd86b45d..7cc23aa88 100644 --- a/packages/taler-wallet-core/src/index.ts +++ b/packages/taler-wallet-core/src/index.ts @@ -66,3 +66,5 @@ export { export * from "./util/timer.js"; export * from "./util/denominations.js"; + +export { SynchronousCryptoWorkerFactoryPlain } from "./crypto/workers/synchronousWorkerFactoryPlain.js"; |