Add SystemAwakeChecker
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -160,6 +160,8 @@ namespace WalletWasabi.Gui
HostedServices.Register(new UpdateChecker(TimeSpan.FromMinutes(7), Synchronizer), "Software Update Checker");
+ HostedServices.Register(new SystemAwakeChecker(TimeSpan.FromMinutes(0.1), WalletManager), "System Awake Checker");
+
#region ProcessKillSubscription
AppDomain.CurrentDomain.ProcessExit += async (s, e) => await DisposeAsync().ConfigureAwait(false);

MODIFY
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
@@ -254,11 +254,6 @@ namespace WalletWasabi.CoinJoin.Client.Clients
using (await MixLock.LockAsync().ConfigureAwait(false))
{
- if (State.AnyCoinsQueued())
- {
- EnvironmentHelpers.KeepSystemAwake();
- }
-
foreach (var ongoingRound in State.GetActivelyMixingRounds())
{
await TryProcessRoundStateAsync(ongoingRound).ConfigureAwait(false);

ADD
WalletWasabi/Services/SystemAwakeChecker.cs
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using WalletWasabi.Bases;
+using WalletWasabi.Helpers;
+using WalletWasabi.Wallets;
+
+namespace WalletWasabi.Services
+{
+ public class SystemAwakeChecker : PeriodicRunner
+ {
+ public SystemAwakeChecker(TimeSpan period, WalletManager walletManager) : base(period)
+ {
+ WalletManager = walletManager;
+ }
+
+ private WalletManager WalletManager { get; }
+
+ protected override Task ActionAsync(CancellationToken cancel)
+ {
+ if (WalletManager.IsAnyCoinJoinInProgress())
+ {
+ EnvironmentHelpers.KeepSystemAwake();
+ }
+
+ return Task.CompletedTask;
+ }
+ }
+}

MODIFY
WalletWasabi/Wallets/WalletManager.cs
WalletWasabi/Wallets/WalletManager.cs
@@ -437,5 +437,13 @@ namespace WalletWasabi.Wallets
return Wallets.Keys.Single(x => x.KeyManager.WalletName == walletName);
}
}
+
+ public bool IsAnyCoinJoinInProgress()
+ {
+ lock (Lock)
+ {
+ return Wallets.Keys.Any(x => x.Coins?.Any(c => c.CoinJoinInProgress) is true);
+ }
+ }
}
}

Add SystemAwakeChecker