Remove ListenRoundConfigFileChanges and tofile for update roundconfig
MODIFY
WalletWasabi.Backend/Config.cs
WalletWasabi.Backend/Config.cs
@@ -45,10 +45,6 @@ namespace WalletWasabi.Backend
[JsonProperty(PropertyName = "RegTestBitcoinCorePort")]
public int? RegTestBitcoinCorePort { get; internal set; }
- [DefaultValue(true)]
- [JsonProperty(PropertyName = "ListenRoundConfigFileChanges", DefaultValueHandling = DefaultValueHandling.Populate)]
- public bool ListenRoundConfigFileChanges { get; set; }
-
private EndPoint _bitcoinCoreEndPoint;
public EndPoint GetBitcoinCoreEndPoint()
@@ -106,8 +102,7 @@ namespace WalletWasabi.Backend
string regTestBitcoinCoreHost,
int? mainNetBitcoinCorePort,
int? testNetBitcoinCorePort,
- int? regTestBitcoinCorePort,
- bool? listenRoundConfigFileChanges)
+ int? regTestBitcoinCorePort)
{
Network = Guard.NotNull(nameof(network), network);
BitcoinRpcConnectionString = Guard.NotNullOrEmptyOrWhitespace(nameof(bitcoinRpcConnectionString), bitcoinRpcConnectionString);
@@ -118,7 +113,6 @@ namespace WalletWasabi.Backend
MainNetBitcoinCorePort = Guard.NotNull(nameof(mainNetBitcoinCorePort), mainNetBitcoinCorePort);
TestNetBitcoinCorePort = Guard.NotNull(nameof(testNetBitcoinCorePort), testNetBitcoinCorePort);
RegTestBitcoinCorePort = Guard.NotNull(nameof(regTestBitcoinCorePort), regTestBitcoinCorePort);
- ListenRoundConfigFileChanges = listenRoundConfigFileChanges ?? true;
}
/// <inheritdoc />
@@ -146,7 +140,6 @@ namespace WalletWasabi.Backend
MainNetBitcoinCorePort = Network.Main.DefaultPort;
TestNetBitcoinCorePort = Network.TestNet.DefaultPort;
RegTestBitcoinCorePort = Network.RegTest.DefaultPort;
- ListenRoundConfigFileChanges = true;
if (!File.Exists(FilePath))
{
Logger.LogInfo<Config>($"{nameof(Config)} file did not exist. Created at path: `{FilePath}`.");
@@ -165,7 +158,6 @@ namespace WalletWasabi.Backend
MainNetBitcoinCorePort = config.MainNetBitcoinCorePort ?? MainNetBitcoinCorePort;
TestNetBitcoinCorePort = config.TestNetBitcoinCorePort ?? TestNetBitcoinCorePort;
RegTestBitcoinCorePort = config.RegTestBitcoinCorePort ?? RegTestBitcoinCorePort;
- ListenRoundConfigFileChanges = config.ListenRoundConfigFileChanges;
}
await ToFileAsync();

MODIFY
WalletWasabi.Backend/Global.cs
WalletWasabi.Backend/Global.cs
@@ -62,14 +62,14 @@ namespace WalletWasabi.Backend
await Coordinator.MakeSureTwoRunningRoundsAsync();
Logger.LogInfo<CcjCoordinator>("Chaumian CoinJoin Coordinator is successfully initialized and started two new rounds.");
- if (config.ListenRoundConfigFileChanges && roundConfig.FilePath != null)
+ if (roundConfig.FilePath != null)
{
RoundConfigWatcher = new ConfigWatcher(RoundConfig);
- RoundConfigWatcher.Start(TimeSpan.FromSeconds(10), () =>
+ RoundConfigWatcher.Start(TimeSpan.FromSeconds(10), async () =>
{
try
{
- Coordinator.UpdateRoundConfig(RoundConfig);
+ await Coordinator.RoundConfig.UpdateOrDefaultAsync(RoundConfig, toFile: false);
Coordinator.AbortAllRoundsInInputRegistration(nameof(ConfigWatcher), $"{nameof(RoundConfig)} has changed.");
}
@@ -77,8 +77,6 @@ namespace WalletWasabi.Backend
{
Logger.LogDebug<ConfigWatcher>(ex);
}
-
- return Task.CompletedTask;
}); // Every 10 seconds check the config
Logger.LogInfo<ConfigWatcher>($"{nameof(RoundConfigWatcher)} is successfully started.");
}

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -1865,7 +1865,7 @@ namespace WalletWasabi.Tests
int anonymitySet = 2;
int connectionConfirmationTimeout = 50;
var roundConfig = RegTestFixture.CreateRoundConfig(denomination, 2, 0.7, coordinatorFeePercent, anonymitySet, 100, connectionConfirmationTimeout, 50, 50, 2, 24, false, 11);
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
Uri baseUri = new Uri(RegTestFixture.BackendEndPoint);
@@ -1982,7 +1982,7 @@ namespace WalletWasabi.Tests
Assert.StartsWith($"{HttpStatusCode.BadRequest.ToReasonString()}\nNot enough inputs are provided. Fee to pay:", httpRequestException.Message);
roundConfig.Denomination = Money.Coins(0.01m); // exactly the same as our output
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
roundId = round.RoundId;
@@ -1992,7 +1992,7 @@ namespace WalletWasabi.Tests
Assert.StartsWith($"{HttpStatusCode.BadRequest.ToReasonString()}\nNot enough inputs are provided. Fee to pay:", httpRequestException.Message);
roundConfig.Denomination = Money.Coins(0.00999999m); // one satoshi less than our output
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
roundId = round.RoundId;
@@ -2003,7 +2003,7 @@ namespace WalletWasabi.Tests
roundConfig.Denomination = Money.Coins(0.008m); // one satoshi less than our output
roundConfig.ConnectionConfirmationTimeout = 2;
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
roundId = round.RoundId;
@@ -2105,7 +2105,7 @@ namespace WalletWasabi.Tests
Assert.Equal(0, inputRegistrableRoundState.RegisteredPeerCount);
roundConfig.ConnectionConfirmationTimeout = 1; // One second.
- coordinator.UpdateRoundConfig(roundConfig); coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true); coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
roundId = round.RoundId;
inputsRequest.RoundId = roundId;
@@ -2195,7 +2195,7 @@ namespace WalletWasabi.Tests
}
roundConfig.ConnectionConfirmationTimeout = 60;
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
roundId = round.RoundId;
@@ -2384,7 +2384,7 @@ namespace WalletWasabi.Tests
int anonymitySet = 4;
int connectionConfirmationTimeout = 50;
var roundConfig = RegTestFixture.CreateRoundConfig(denomination, 2, 0.7, coordinatorFeePercent, anonymitySet, 100, connectionConfirmationTimeout, 50, 50, 2, 24, false, 11);
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
Uri baseUri = new Uri(RegTestFixture.BackendEndPoint);
@@ -2533,7 +2533,7 @@ namespace WalletWasabi.Tests
int connectionConfirmationTimeout = 1;
bool doesNoteBeforeBan = true;
CcjRoundConfig roundConfig = RegTestFixture.CreateRoundConfig(denomination, 140, 0.7, coordinatorFeePercent, anonymitySet, 240, connectionConfirmationTimeout, 1, 1, 1, 24, doesNoteBeforeBan, 11);
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
Uri baseUri = new Uri(RegTestFixture.BackendEndPoint);
@@ -2613,7 +2613,7 @@ namespace WalletWasabi.Tests
int anonymitySet = 3;
int connectionConfirmationTimeout = 120;
var roundConfig = RegTestFixture.CreateRoundConfig(denomination, 140, 0.7, coordinatorFeePercent, anonymitySet, 240, connectionConfirmationTimeout, 1, 1, 1, 24, true, 11);
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
await rpc.GenerateAsync(3); // So to make sure we have enough money.
@@ -2815,7 +2815,7 @@ namespace WalletWasabi.Tests
int anonymitySet = 100;
int connectionConfirmationTimeout = 120;
var roundConfig = RegTestFixture.CreateRoundConfig(denomination, Constants.OneDayConfirmationTarget, 0.7, coordinatorFeePercent, anonymitySet, 240, connectionConfirmationTimeout, 50, 50, 1, 24, true, 11);
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
await rpc.GenerateAsync(100); // So to make sure we have enough money.
@@ -3035,7 +3035,7 @@ namespace WalletWasabi.Tests
int anonymitySet = 7;
int connectionConfirmationTimeout = 14;
var roundConfig = RegTestFixture.CreateRoundConfig(denomination, 140, 0.7, coordinatorFeePercent, anonymitySet, 240, connectionConfirmationTimeout, 50, 50, 1, 24, true, 11);
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
var participants = new List<dynamic>();
@@ -3159,7 +3159,7 @@ namespace WalletWasabi.Tests
int anonymitySet = 2;
int connectionConfirmationTimeout = 14;
var roundConfig = RegTestFixture.CreateRoundConfig(denomination, 140, 0.7, coordinatorFeePercent, anonymitySet, 240, connectionConfirmationTimeout, 50, 50, 1, 24, true, 11);
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
await rpc.GenerateAsync(3); // So to make sure we have enough money.
var keyManager = KeyManager.CreateNew(out _, password);
@@ -3259,7 +3259,7 @@ namespace WalletWasabi.Tests
// Make sure if times out, it tries again.
connectionConfirmationTimeout = 1;
roundConfig = RegTestFixture.CreateRoundConfig(denomination, 140, 0.7, coordinatorFeePercent, anonymitySet, 240, connectionConfirmationTimeout, 50, 50, 1, 24, true, 11);
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
Assert.NotEmpty(chaumianClient1.State.GetAllQueuedCoins());
await chaumianClient1.DequeueAllCoinsFromMixAsync("");
@@ -3312,7 +3312,7 @@ namespace WalletWasabi.Tests
int anonymitySet = 2;
int connectionConfirmationTimeout = 14;
var roundConfig = RegTestFixture.CreateRoundConfig(denomination, 140, 0.7, coordinatorFeePercent, anonymitySet, 240, connectionConfirmationTimeout, 50, 50, 1, 24, true, 11);
- coordinator.UpdateRoundConfig(roundConfig);
+ await coordinator.RoundConfig.UpdateOrDefaultAsync(roundConfig, toFile: true);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
// Create the services.

MODIFY
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
@@ -36,7 +36,7 @@ namespace WalletWasabi.Tests.XunitConfiguration
UserPassword = BackendRegTestNode.Creds
}.ToString();
var global = new Backend.Global();
- var config = new Config(BackendNodeBuilder.Network, connectionString, IPAddress.Loopback.ToString(), IPAddress.Loopback.ToString(), BackendRegTestNode.Endpoint.Address.ToString(), Network.Main.DefaultPort, Network.TestNet.DefaultPort, BackendRegTestNode.Endpoint.Port, false);
+ var config = new Config(BackendNodeBuilder.Network, connectionString, IPAddress.Loopback.ToString(), IPAddress.Loopback.ToString(), BackendRegTestNode.Endpoint.Address.ToString(), Network.Main.DefaultPort, Network.TestNet.DefaultPort, BackendRegTestNode.Endpoint.Port);
var configFilePath = Path.Combine(global.DataDir, "Config.json");
config.SetFilePath(configFilePath);
config.ToFileAsync().GetAwaiter().GetResult();

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjRoundConfig.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjRoundConfig.cs
@@ -106,13 +106,13 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
string jsonString = await File.ReadAllTextAsync(FilePath, Encoding.UTF8);
var config = JsonConvert.DeserializeObject<CcjRoundConfig>(jsonString);
- UpdateOrDefault(config);
+ await UpdateOrDefaultAsync(config, toFile: false);
}
await ToFileAsync();
}
- public void UpdateOrDefault(CcjRoundConfig config)
+ public async Task UpdateOrDefaultAsync(CcjRoundConfig config, bool toFile)
{
Denomination = config.Denomination ?? Denomination;
ConfirmationTarget = config.ConfirmationTarget ?? ConfirmationTarget;
@@ -127,6 +127,11 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
DosDurationHours = config.DosDurationHours ?? DosDurationHours;
DosNoteBeforeBan = config.DosNoteBeforeBan ?? DosNoteBeforeBan;
MaximumMixingLevelCount = config.MaximumMixingLevelCount ?? MaximumMixingLevelCount;
+
+ if (toFile)
+ {
+ await ToFileAsync();
+ }
}
/// <inheritdoc />

MODIFY
WalletWasabi/Services/CcjCoordinator.cs
WalletWasabi/Services/CcjCoordinator.cs
@@ -194,11 +194,6 @@ namespace WalletWasabi.Services
}
}
- public void UpdateRoundConfig(CcjRoundConfig roundConfig)
- {
- RoundConfig.UpdateOrDefault(roundConfig);
- }
-
public async Task MakeSureTwoRunningRoundsAsync(Money feePerInputs = null, Money feePerOutputs = null)
{
using (await RoundsListLock.LockAsync())

Remove ListenRoundConfigFileChanges and tofile for update roundconfig