From 53be1f53dbd4335ba03887da40e1450fefd73afe Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 8 Jun 2023 14:25:09 -0600 Subject: [PATCH] fix: old block errors --- lib/services/coins/banano/banano_wallet.dart | 30 ++++++++++++++------ lib/services/coins/nano/nano_wallet.dart | 30 ++++++++++++++------ 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/lib/services/coins/banano/banano_wallet.dart b/lib/services/coins/banano/banano_wallet.dart index 1240ac446..d44075d09 100644 --- a/lib/services/coins/banano/banano_wallet.dart +++ b/lib/services/coins/banano/banano_wallet.dart @@ -733,17 +733,29 @@ class BananoWallet extends CoinServiceAPI @override Future refresh() async { + if (refreshMutex) { + Logging.instance.log( + "$walletId $walletName refreshMutex denied", + level: LogLevel.Info, + ); + return; + } else { + refreshMutex = true; + } + await _prefs.init(); - GlobalEventBus.instance.fire( - WalletSyncStatusChangedEvent( - WalletSyncStatus.syncing, - walletId, - coin, - ), - ); - try { + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.syncing, + walletId, + coin, + ), + ); + + await _prefs.init(); + await updateChainHeight(); await updateTransactions(); await updateBalance(); @@ -768,6 +780,8 @@ class BananoWallet extends CoinServiceAPI ), ); } + + refreshMutex = false; } @override diff --git a/lib/services/coins/nano/nano_wallet.dart b/lib/services/coins/nano/nano_wallet.dart index 31114eef2..1f525d86d 100644 --- a/lib/services/coins/nano/nano_wallet.dart +++ b/lib/services/coins/nano/nano_wallet.dart @@ -747,17 +747,27 @@ class NanoWallet extends CoinServiceAPI @override Future refresh() async { - await _prefs.init(); - - GlobalEventBus.instance.fire( - WalletSyncStatusChangedEvent( - WalletSyncStatus.syncing, - walletId, - coin, - ), - ); + if (refreshMutex) { + Logging.instance.log( + "$walletId $walletName refreshMutex denied", + level: LogLevel.Info, + ); + return; + } else { + refreshMutex = true; + } try { + await _prefs.init(); + + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.syncing, + walletId, + coin, + ), + ); + await updateChainHeight(); await updateTransactions(); await updateBalance(); @@ -782,6 +792,8 @@ class NanoWallet extends CoinServiceAPI ), ); } + + refreshMutex = false; } @override