mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 17:57:36 +00:00
untested round robin
This commit is contained in:
parent
4411f7bea6
commit
e37c01b4d7
1 changed files with 22 additions and 5 deletions
|
@ -162,7 +162,7 @@ Future<void> onStart(ServiceInstance service) async {
|
|||
final wallet = await walletLoadingService.load(moneroWallets[i].type, moneroWallets[i].name);
|
||||
final node = settingsStore.getCurrentNode(moneroWallets[i].type);
|
||||
wallet.connectToNode(node: node);
|
||||
wallet.startSync();
|
||||
wallet.stopSync();
|
||||
syncingWallets.add(wallet);
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,7 @@ Future<void> onStart(ServiceInstance service) async {
|
|||
final wallet = await walletLoadingService.load(firstWallet.type, firstWallet.name);
|
||||
final node = settingsStore.getCurrentNode(WalletType.litecoin);
|
||||
wallet.connectToNode(node: node);
|
||||
wallet.stopSync();
|
||||
// calling start sync isn't necessary since it's called after connecting to the node
|
||||
syncingWallets.add(wallet);
|
||||
} catch (e) {
|
||||
|
@ -207,6 +208,8 @@ Future<void> onStart(ServiceInstance service) async {
|
|||
continue;
|
||||
}
|
||||
|
||||
wallet.stopSync();
|
||||
|
||||
syncingWallets.add(wallet);
|
||||
} catch (e) {
|
||||
print("error syncing bitcoin wallet_$i: $e");
|
||||
|
@ -214,16 +217,26 @@ Future<void> onStart(ServiceInstance service) async {
|
|||
}
|
||||
|
||||
print("STARTING SYNC TIMER");
|
||||
int currentSyncingWallet = 0;
|
||||
_syncTimer?.cancel();
|
||||
if (syncingWallets.isEmpty) return;
|
||||
syncingWallets.first!.startSync();
|
||||
_syncTimer = Timer.periodic(const Duration(milliseconds: 2000), (timer) {
|
||||
if (syncingWallets.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < syncingWallets.length; i++) {
|
||||
final wallet = syncingWallets[i];
|
||||
if (wallet == null) continue;
|
||||
|
||||
if (wallet.syncStatus.progress() > 0.99) {
|
||||
print("WALLET $i SYNCED");
|
||||
wallet.stopSync();
|
||||
currentSyncingWallet++;
|
||||
if (currentSyncingWallet < syncingWallets.length) {
|
||||
syncingWallets[currentSyncingWallet]!.startSync();
|
||||
} else {
|
||||
currentSyncingWallet = 0;
|
||||
}
|
||||
}
|
||||
|
||||
final syncProgress = ((wallet.syncStatus.progress()) * 100).toStringAsPrecision(5);
|
||||
|
||||
String prefix = walletTypeToCryptoCurrency(wallet.type).title;
|
||||
|
@ -254,6 +267,10 @@ Future<void> onStart(ServiceInstance service) async {
|
|||
}
|
||||
content += " - ${DateTime.now().toIso8601String()}";
|
||||
|
||||
if (i != currentSyncingWallet) {
|
||||
content = "${syncProgress}% PAUSED - Waiting for other wallets to finish";
|
||||
}
|
||||
|
||||
flutterLocalNotificationsPlugin.show(
|
||||
notificationId + i,
|
||||
title,
|
||||
|
|
Loading…
Reference in a new issue