Move ShieldLevelHelper inside the Config class
MODIFY
WalletWasabi.Gui/Config.cs
WalletWasabi.Gui/Config.cs
@@ -528,5 +528,72 @@ namespace WalletWasabi.Gui
throw new NotSupportedException($"{nameof(FilePath)} is not set. Use {nameof(SetFilePath)} to set it.");
}
}
+
+ public enum TargetPrivacy
+ {
+ None,
+ Some,
+ Fine,
+ Strong,
+ }
+
+ public TargetPrivacy GetTargetPrivacy()
+ {
+ if (MixUntilAnonymitySet == PrivacyLevelSome)
+ {
+ return TargetPrivacy.Some;
+ }
+
+ if (MixUntilAnonymitySet == PrivacyLevelFine)
+ {
+ return TargetPrivacy.Fine;
+ }
+
+ if (MixUntilAnonymitySet == PrivacyLevelStrong)
+ {
+ return TargetPrivacy.Strong;
+ }
+ //the levels changed in the config file, adjust
+ if (MixUntilAnonymitySet < PrivacyLevelSome)
+ {
+ return TargetPrivacy.None; //choose the lower
+ }
+
+ if (MixUntilAnonymitySet < PrivacyLevelFine)
+ {
+ return TargetPrivacy.Some;
+ }
+
+ if (MixUntilAnonymitySet < PrivacyLevelStrong)
+ {
+ return TargetPrivacy.Fine;
+ }
+
+ if (MixUntilAnonymitySet > PrivacyLevelFine)
+ {
+ return TargetPrivacy.Strong;
+ }
+
+ return TargetPrivacy.None;
+ }
+
+ public int GetTargetLevel(TargetPrivacy target)
+ {
+ switch (target)
+ {
+ case TargetPrivacy.None:
+ return 0;
+
+ case TargetPrivacy.Some:
+ return PrivacyLevelSome.Value;
+
+ case TargetPrivacy.Fine:
+ return PrivacyLevelFine.Value;
+
+ case TargetPrivacy.Strong:
+ return PrivacyLevelStrong.Value;
+ }
+ return 0;
+ }
}
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -15,7 +15,7 @@ using WalletWasabi.KeyManagement;
using WalletWasabi.Logging;
using WalletWasabi.Models.ChaumianCoinJoin;
using WalletWasabi.Services;
-using static WalletWasabi.Gui.Models.ShieldLevelHelper;
+using static WalletWasabi.Gui.Config;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -118,7 +118,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
this.WhenAnyValue(x => x.TargetPrivacy).Subscribe(target =>
{
- CoinJoinUntilAnonimitySet = GetTargetLevel(target);
+ CoinJoinUntilAnonimitySet = Global.Instance.Config.GetTargetLevel(target);
});
}
@@ -133,7 +133,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Disposables = new CompositeDisposable();
- TargetPrivacy = GetTargetPrivacy(Global.Instance.Config.MixUntilAnonymitySet);
+ TargetPrivacy = Global.Instance.Config.GetTargetPrivacy();
var registrableRound = Global.Instance.ChaumianClient.State.GetRegistrableRoundOrDefault();

DELETE
WalletWasabi.Gui/Models/ShieldLevelHelper.cs
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace WalletWasabi.Gui.Models
-{
- public static class ShieldLevelHelper
- {
- public enum TargetPrivacy
- {
- None,
- Some,
- Fine,
- Strong,
- }
-
- public static TargetPrivacy GetTargetPrivacy(int? mixUntilAnonymitySet)
- {
- if (mixUntilAnonymitySet == Global.Instance.Config.PrivacyLevelSome)
- {
- return TargetPrivacy.Some;
- }
-
- if (mixUntilAnonymitySet == Global.Instance.Config.PrivacyLevelFine)
- {
- return TargetPrivacy.Fine;
- }
-
- if (mixUntilAnonymitySet == Global.Instance.Config.PrivacyLevelStrong)
- {
- return TargetPrivacy.Strong;
- }
- //the levels changed in the config file, adjust
- if (mixUntilAnonymitySet < Global.Instance.Config.PrivacyLevelSome)
- {
- return TargetPrivacy.None; //choose the lower
- }
-
- if (mixUntilAnonymitySet < Global.Instance.Config.PrivacyLevelFine)
- {
- return TargetPrivacy.Some;
- }
-
- if (mixUntilAnonymitySet < Global.Instance.Config.PrivacyLevelStrong)
- {
- return TargetPrivacy.Fine;
- }
-
- if (mixUntilAnonymitySet > Global.Instance.Config.PrivacyLevelFine)
- {
- return TargetPrivacy.Strong;
- }
-
- return TargetPrivacy.None;
- }
-
- public static int GetTargetLevel(TargetPrivacy target)
- {
- switch (target)
- {
- case TargetPrivacy.None:
- return 0;
-
- case TargetPrivacy.Some:
- return Global.Instance.Config.PrivacyLevelSome.Value;
-
- case TargetPrivacy.Fine:
- return Global.Instance.Config.PrivacyLevelFine.Value;
-
- case TargetPrivacy.Strong:
- return Global.Instance.Config.PrivacyLevelStrong.Value;
- }
- return 0;
- }
-
- public static int AdjustTargetLevel(int mixUntilAnonymitySet)
- {
- var res = GetTargetPrivacy(mixUntilAnonymitySet); // select a valid level
- return GetTargetLevel(res);
- }
- }
-}

Move ShieldLevelHelper inside the Config class