mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
Prevent app lag when node is exceptionally slow (usually over tor)
This commit is contained in:
parent
812c5e6e53
commit
179f039e31
4 changed files with 32 additions and 5 deletions
|
@ -146,7 +146,21 @@ int getUnlockedBalance({int accountIndex = 0}) =>
|
|||
|
||||
int getCurrentHeight() => currentWallet?.blockChainHeight() ?? 0;
|
||||
|
||||
int getNodeHeightSync() => currentWallet?.daemonBlockChainHeight() ?? 0;
|
||||
|
||||
bool isHeightRefreshing = false;
|
||||
int cachedNodeHeight = 0;
|
||||
int getNodeHeightSync() {
|
||||
if (isHeightRefreshing == false) {
|
||||
(() async {
|
||||
final wptrAddress = currentWallet!.ffiAddress();
|
||||
cachedNodeHeight = await Isolate.run(() async {
|
||||
return monero.Wallet_daemonBlockChainHeight(Pointer.fromAddress(wptrAddress));
|
||||
});
|
||||
isHeightRefreshing = true;
|
||||
})();
|
||||
}
|
||||
return cachedNodeHeight;
|
||||
}
|
||||
|
||||
bool isConnectedSync() => currentWallet?.connected() != 0;
|
||||
|
||||
|
|
|
@ -110,8 +110,19 @@ int getUnlockedBalance({int accountIndex = 0}) =>
|
|||
|
||||
int getCurrentHeight() => wownero.Wallet_blockChainHeight(wptr!);
|
||||
|
||||
int getNodeHeightSync() => wownero.Wallet_daemonBlockChainHeight(wptr!);
|
||||
|
||||
bool isHeightRefreshing = false;
|
||||
int cachedNodeHeight = 0;
|
||||
int getNodeHeightSync() {
|
||||
if (isHeightRefreshing == false) {
|
||||
(() async {
|
||||
cachedNodeHeight = await Isolate.run(() async {
|
||||
return wownero.Wallet_daemonBlockChainHeight(wptr!);
|
||||
});
|
||||
isHeightRefreshing = true;
|
||||
})();
|
||||
}
|
||||
return cachedNodeHeight;
|
||||
}
|
||||
bool isConnectedSync() => wownero.Wallet_connected(wptr!) != 0;
|
||||
|
||||
Future<bool> setupNodeSync(
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:cw_core/node.dart';
|
|||
import 'package:cake_wallet/entities/node_list.dart';
|
||||
import 'package:cake_wallet/entities/default_settings_migration.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:tor/tor.dart';
|
||||
|
||||
part 'node_list_view_model.g.dart';
|
||||
|
||||
|
@ -38,7 +39,7 @@ abstract class NodeListViewModelBase with Store {
|
|||
|
||||
String getAlertContent(String uri) =>
|
||||
S.current.change_current_node(uri) +
|
||||
'${uri.endsWith('.onion') || uri.contains('.onion:') ? '\n' + S.current.orbot_running_alert : ''}';
|
||||
'${uri.endsWith('.onion') || uri.contains('.onion:') ? '\n' + (Tor.instance.enabled ? '' : S.current.orbot_running_alert) : ''}';
|
||||
|
||||
final ObservableList<Node> nodes;
|
||||
final SettingsStore settingsStore;
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:cw_core/node.dart';
|
|||
import 'package:cake_wallet/entities/node_list.dart';
|
||||
import 'package:cake_wallet/entities/default_settings_migration.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:tor/tor.dart';
|
||||
|
||||
part 'pow_node_list_view_model.g.dart';
|
||||
|
||||
|
@ -38,7 +39,7 @@ abstract class PowNodeListViewModelBase with Store {
|
|||
|
||||
String getAlertContent(String uri) =>
|
||||
S.current.change_current_node(uri) +
|
||||
'${uri.endsWith('.onion') || uri.contains('.onion:') ? '\n' + S.current.orbot_running_alert : ''}';
|
||||
'${uri.endsWith('.onion') || uri.contains('.onion:') ? '\n' + (Tor.instance.enabled ? '' : S.current.orbot_running_alert) : ''}';
|
||||
|
||||
final ObservableList<Node> nodes;
|
||||
final SettingsStore settingsStore;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue