From e68cae6bf48ff386710d28d4c39b853237a2d851 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Sun, 12 May 2024 08:18:24 +0200 Subject: [PATCH] make init async so it won't lag disable print starts --- cw_monero/lib/api/wallet.dart | 21 ++++++++++++--------- cw_monero/lib/api/wallet_manager.dart | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cw_monero/lib/api/wallet.dart b/cw_monero/lib/api/wallet.dart index 63277e6a3..16bbe8018 100644 --- a/cw_monero/lib/api/wallet.dart +++ b/cw_monero/lib/api/wallet.dart @@ -59,13 +59,13 @@ int getNodeHeightSync() => monero.Wallet_daemonBlockChainHeight(wptr!); bool isConnectedSync() => monero.Wallet_connected(wptr!) != 0; -bool setupNodeSync( +Future setupNodeSync( {required String address, String? login, String? password, bool useSSL = false, bool isLightWallet = false, - String? socksProxyAddress}) { + String? socksProxyAddress}) async { print(''' { wptr!, @@ -76,12 +76,15 @@ bool setupNodeSync( daemonPassword: $password ?? '' } '''); - monero.Wallet_init(wptr!, - daemonAddress: address, - useSsl: useSSL, - proxyAddress: socksProxyAddress ?? '', - daemonUsername: login ?? '', - daemonPassword: password ?? ''); + final addr = wptr!.address; + await Isolate.run(() { + monero.Wallet_init(Pointer.fromAddress(addr), + daemonAddress: address, + useSsl: useSSL, + proxyAddress: socksProxyAddress ?? '', + daemonUsername: login ?? '', + daemonPassword: password ?? ''); + }); // monero.Wallet_init3(wptr!, argv0: '', defaultLogBaseName: 'moneroc', console: true); final status = monero.Wallet_status(wptr!); @@ -219,7 +222,7 @@ void onStartup() {} void _storeSync(Object _) => storeSync(); -bool _setupNodeSync(Map args) { +Future _setupNodeSync(Map args) async { final address = args['address'] as String; final login = (args['login'] ?? '') as String; final password = (args['password'] ?? '') as String; diff --git a/cw_monero/lib/api/wallet_manager.dart b/cw_monero/lib/api/wallet_manager.dart index f5e467f9e..cf1ee7dce 100644 --- a/cw_monero/lib/api/wallet_manager.dart +++ b/cw_monero/lib/api/wallet_manager.dart @@ -16,7 +16,7 @@ final monero.WalletManager wmPtr = Pointer.fromAddress((() { // Problems with the wallet? Crashes? Lags? this will print all calls to xmr // codebase, so it will be easier to debug what happens. At least easier // than plugging gdb in. Especially on windows/android. - monero.printStarts = kDebugMode; + monero.printStarts = false; _wmPtr ??= monero.WalletManagerFactory_getWalletManager(); print("ptr: $_wmPtr"); } catch (e) {