Redo update logic
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -142,7 +142,7 @@ namespace WalletWasabi.Gui
Synchronizer = new WasabiSynchronizer(Network, BitcoinStore, Config.GetFallbackBackendUri(), null);
}
- HostedServices.Register(new UpdateChecker(TimeSpan.FromMinutes(7), Synchronizer.WasabiClient), "Software Update Checker");
+ HostedServices.Register(new UpdateChecker(TimeSpan.FromMinutes(7), Synchronizer), "Software Update Checker");
#region ProcessKillSubscription

MODIFY
WalletWasabi.Gui/Tabs/AboutViewModel.cs
WalletWasabi.Gui/Tabs/AboutViewModel.cs
@@ -65,17 +65,17 @@ namespace WalletWasabi.Gui.Tabs
{
base.OnOpen(disposables);
- WasabiClient.CurrentBackendMajorVersionUpdated += WasabiClient_CurrentBackendMajorVersionUpdated;
+ WasabiClient.CurrentBackendMajorVersionChanged += WasabiClient_CurrentBackendMajorVersionChanged;
}
public override bool OnClose()
{
- WasabiClient.CurrentBackendMajorVersionUpdated -= WasabiClient_CurrentBackendMajorVersionUpdated;
+ WasabiClient.CurrentBackendMajorVersionChanged -= WasabiClient_CurrentBackendMajorVersionChanged;
return base.OnClose();
}
- private void WasabiClient_CurrentBackendMajorVersionUpdated(object sender, string currentBackendMajorVersion)
+ private void WasabiClient_CurrentBackendMajorVersionChanged(object sender, string currentBackendMajorVersion)
{
CurrentBackendMajorVersion = currentBackendMajorVersion;
}

MODIFY
WalletWasabi/Services/UpdateChecker.cs
WalletWasabi/Services/UpdateChecker.cs
@@ -15,16 +15,21 @@ namespace WalletWasabi.Services
{
private UpdateStatus _updateStatus;
- public UpdateChecker(TimeSpan period, WasabiClient client) : base(period)
+ public UpdateChecker(TimeSpan period, WasabiSynchronizer synchronizer) : base(period)
{
- WasabiClient = Guard.NotNull(nameof(client), client);
+ Synchronizer = Guard.NotNull(nameof(synchronizer), synchronizer);
+ WasabiClient = synchronizer.WasabiClient;
UpdateStatus = new UpdateStatus(true, true, new Version());
+
+ Synchronizer.PropertyChanged += Synchronizer_PropertyChanged;
}
public event EventHandler<UpdateStatus> UpdateStatusChanged;
public WasabiClient WasabiClient { get; }
+ public WasabiSynchronizer Synchronizer { get; }
+
public UpdateStatus UpdateStatus
{
get => _updateStatus;
@@ -38,9 +43,25 @@ namespace WalletWasabi.Services
}
}
+ private void Synchronizer_PropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == nameof(WasabiSynchronizer.BackendStatus) &&
+ Synchronizer.BackendStatus == BackendStatus.Connected)
+ {
+ // Any time when the synchronizer detects the backend, we immediately check the versions.
+ TriggerRound();
+ }
+ }
+
protected override async Task ActionAsync(CancellationToken cancel)
{
UpdateStatus = await WasabiClient.CheckUpdatesAsync(cancel).ConfigureAwait(false);
}
+
+ public override void Dispose()
+ {
+ Synchronizer.PropertyChanged -= Synchronizer_PropertyChanged;
+ base.Dispose();
+ }
}
}

MODIFY
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
@@ -35,7 +35,7 @@ namespace WalletWasabi.WebClients.Wasabi
{
}
- public static event EventHandler<string> CurrentBackendMajorVersionUpdated;
+ public static event EventHandler<string> CurrentBackendMajorVersionChanged;
public static Dictionary<uint256, Transaction> TransactionCache { get; } = new Dictionary<uint256, Transaction>();
private static Queue<uint256> TransactionIdQueue { get; } = new Queue<uint256>();
@@ -261,8 +261,12 @@ namespace WalletWasabi.WebClients.Wasabi
var versions = await GetVersionsAsync(cancel);
var clientUpToDate = Constants.ClientVersion >= versions.ClientVersion; // If the client version locally is greater than or equal to the backend's reported client version, then good.
var backendCompatible = int.Parse(Constants.ClientSupportBackendVersionMax) >= versions.BackendMajorVersion && versions.BackendMajorVersion >= int.Parse(Constants.ClientSupportBackendVersionMin); // If ClientSupportBackendVersionMin <= backend major <= ClientSupportBackendVersionMax, then our software is compatible.
- CurrentBackendMajorVersion = versions.BackendMajorVersion.ToString();
- CurrentBackendMajorVersionUpdated?.Invoke(this, CurrentBackendMajorVersion);
+ var currentBackendMajorVersion = versions.BackendMajorVersion.ToString();
+ if (CurrentBackendMajorVersion != currentBackendMajorVersion)
+ {
+ CurrentBackendMajorVersion = currentBackendMajorVersion;
+ CurrentBackendMajorVersionChanged?.Invoke(this, CurrentBackendMajorVersion);
+ }
return new UpdateStatus(backendCompatible, clientUpToDate, versions.LegalDocumentsVersion);
}

Redo update logic