embedded wallet: improve 'init' request
Allow specifying crypto worker type, pass through version info from 'initWallet'.
This commit is contained in:
parent
ec7a3c8133
commit
c2e7510cec
@ -174,6 +174,7 @@ export async function getDefaultNodeWallet2(
|
|||||||
const worker_threads = module[_r]("worker_threads");
|
const worker_threads = module[_r]("worker_threads");
|
||||||
// require("worker_threads");
|
// require("worker_threads");
|
||||||
workerFactory = new NodeThreadCryptoWorkerFactory();
|
workerFactory = new NodeThreadCryptoWorkerFactory();
|
||||||
|
logger.info("using node thread crypto worker");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"worker threads not available, falling back to synchronous workers",
|
"worker threads not available, falling back to synchronous workers",
|
||||||
|
@ -18,31 +18,30 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
getDefaultNodeWallet,
|
|
||||||
DefaultNodeWalletArgs,
|
DefaultNodeWalletArgs,
|
||||||
NodeHttpLib,
|
getDefaultNodeWallet,
|
||||||
|
getErrorDetailFromException,
|
||||||
handleWorkerError,
|
handleWorkerError,
|
||||||
handleWorkerMessage,
|
handleWorkerMessage,
|
||||||
HttpRequestLibrary,
|
|
||||||
OpenedPromise,
|
|
||||||
HttpResponse,
|
|
||||||
HttpRequestOptions,
|
|
||||||
openPromise,
|
|
||||||
Headers,
|
Headers,
|
||||||
|
HttpRequestLibrary,
|
||||||
|
HttpRequestOptions,
|
||||||
|
HttpResponse,
|
||||||
|
NodeHttpLib,
|
||||||
|
OpenedPromise,
|
||||||
|
openPromise,
|
||||||
|
Wallet,
|
||||||
WALLET_EXCHANGE_PROTOCOL_VERSION,
|
WALLET_EXCHANGE_PROTOCOL_VERSION,
|
||||||
WALLET_MERCHANT_PROTOCOL_VERSION,
|
WALLET_MERCHANT_PROTOCOL_VERSION,
|
||||||
Wallet,
|
|
||||||
getErrorDetailFromException,
|
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
import fs from "fs";
|
|
||||||
import {
|
import {
|
||||||
CoreApiEnvelope,
|
CoreApiEnvelope,
|
||||||
CoreApiResponse,
|
CoreApiResponse,
|
||||||
CoreApiResponseSuccess,
|
CoreApiResponseSuccess,
|
||||||
WalletNotification,
|
WalletNotification,
|
||||||
TalerErrorCode,
|
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
export { handleWorkerError, handleWorkerMessage };
|
export { handleWorkerError, handleWorkerMessage };
|
||||||
|
|
||||||
@ -175,10 +174,17 @@ class NativeWalletMessageHandler {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let initResponse: any = {};
|
||||||
|
|
||||||
const reinit = async () => {
|
const reinit = async () => {
|
||||||
const w = await getDefaultNodeWallet(this.walletArgs);
|
const w = await getDefaultNodeWallet(this.walletArgs);
|
||||||
this.maybeWallet = w;
|
this.maybeWallet = w;
|
||||||
await w.handleCoreApiRequest("initWallet", "native-init", {});
|
const resp = await w.handleCoreApiRequest(
|
||||||
|
"initWallet",
|
||||||
|
"native-init",
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
initResponse = resp.type == "response" ? resp.result : resp.error;
|
||||||
w.runTaskLoop().catch((e) => {
|
w.runTaskLoop().catch((e) => {
|
||||||
console.error("Error during wallet retry loop", e);
|
console.error("Error during wallet retry loop", e);
|
||||||
});
|
});
|
||||||
@ -193,13 +199,17 @@ class NativeWalletMessageHandler {
|
|||||||
},
|
},
|
||||||
persistentStoragePath: args.persistentStoragePath,
|
persistentStoragePath: args.persistentStoragePath,
|
||||||
httpLib: this.httpLib,
|
httpLib: this.httpLib,
|
||||||
|
cryptoWorkerType: args.cryptoWorkerType,
|
||||||
};
|
};
|
||||||
await reinit();
|
await reinit();
|
||||||
return wrapResponse({
|
return wrapResponse({
|
||||||
|
// FIXME: Only for Android compatibility, should be removed
|
||||||
|
// once changed on Android.
|
||||||
supported_protocol_versions: {
|
supported_protocol_versions: {
|
||||||
exchange: WALLET_EXCHANGE_PROTOCOL_VERSION,
|
exchange: WALLET_EXCHANGE_PROTOCOL_VERSION,
|
||||||
merchant: WALLET_MERCHANT_PROTOCOL_VERSION,
|
merchant: WALLET_MERCHANT_PROTOCOL_VERSION,
|
||||||
},
|
},
|
||||||
|
...initResponse,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case "startTunnel": {
|
case "startTunnel": {
|
||||||
|
Loading…
Reference in New Issue
Block a user