Add IndexDownloader
MODIFY
WalletWasabi.Gui/Config.cs
WalletWasabi.Gui/Config.cs
@@ -22,6 +22,14 @@ namespace WalletWasabi.Gui
[JsonConverter(typeof(NetworkJsonConverter))]
public Network Network { get; private set; }
+ [JsonProperty(PropertyName = "TestNetBackendUri")]
+ public string TestNetBackendUri { get; private set; }
+
+ [JsonProperty(PropertyName = "MainNetBackendUri")]
+ public string MainNetBackendUri { get; private set; }
+
+ public Uri GetCurrentUri() => Network == Network.Main ? new Uri(MainNetBackendUri) : new Uri(TestNetBackendUri);
+
public Config()
{
}
@@ -31,9 +39,11 @@ namespace WalletWasabi.Gui
SetFilePath(filePath);
}
- public Config(Network network)
+ public Config(Network network, string testNetBackendUri, string mainNetBackendUri)
{
Network = Guard.NotNull(nameof(network), network);
+ TestNetBackendUri = Guard.NotNullOrEmptyOrWhitespace(nameof(testNetBackendUri), testNetBackendUri);
+ MainNetBackendUri = Guard.NotNullOrEmptyOrWhitespace(nameof(mainNetBackendUri), mainNetBackendUri);
}
/// <inheritdoc />
@@ -53,6 +63,8 @@ namespace WalletWasabi.Gui
AssertFilePathSet();
Network = Network.Main;
+ TestNetBackendUri = "http://wtgjmaol3io5ijii.onion/";
+ MainNetBackendUri = "http://4jsmnfcsmbrlm7l7.onion/";
if (!File.Exists(FilePath))
{
@@ -64,6 +76,8 @@ namespace WalletWasabi.Gui
var config = JsonConvert.DeserializeObject<Config>(jsonString);
Network = config.Network ?? Network;
+ TestNetBackendUri = config.TestNetBackendUri ?? TestNetBackendUri;
+ MainNetBackendUri = config.MainNetBackendUri ?? MainNetBackendUri;
}
await ToFileAsync();
@@ -87,6 +101,16 @@ namespace WalletWasabi.Gui
return true;
}
+ if (!TestNetBackendUri.Equals(config.TestNetBackendUri, StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ if (!MainNetBackendUri.Equals(config.MainNetBackendUri, StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
return false;
}

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -267,10 +267,7 @@ namespace WalletWasabi.Tests
}
finally
{
- if (downloader != null)
- {
- await downloader.StopAsync();
- }
+ downloader?.Stop();
}
}
@@ -376,10 +373,7 @@ namespace WalletWasabi.Tests
{
downloader.Reorged -= ReorgTestAsync_Downloader_Reorged;
- if (downloader != null)
- {
- await downloader.StopAsync();
- }
+ downloader?.Stop();
}
}
@@ -601,10 +595,7 @@ namespace WalletWasabi.Tests
wallet.NewFilterProcessed -= Wallet_NewFilterProcessed;
wallet?.Dispose();
// Dispose index downloader service.
- if (indexDownloader != null)
- {
- await indexDownloader.StopAsync();
- }
+ indexDownloader?.Stop();
// Dispose mempool service.
memPoolService.TransactionReceived -= WalletTestsAsync_MemPoolService_TransactionReceived;
@@ -1073,10 +1064,7 @@ namespace WalletWasabi.Tests
wallet.NewFilterProcessed -= Wallet_NewFilterProcessed;
wallet?.Dispose();
// Dispose index downloader service.
- if (indexDownloader != null)
- {
- await indexDownloader.StopAsync();
- }
+ indexDownloader?.Stop();
// Dispose connection service.
nodes?.Dispose();
// Dispose chaumian coinjoin client.
@@ -1253,10 +1241,7 @@ namespace WalletWasabi.Tests
{
wallet?.Dispose();
// Dispose index downloader service.
- if (indexDownloader != null)
- {
- await indexDownloader.StopAsync();
- }
+ indexDownloader?.Stop();
// Dispose connection service.
nodes?.Dispose();
// Dispose chaumian coinjoin client.
@@ -1424,10 +1409,7 @@ namespace WalletWasabi.Tests
{
wallet?.Dispose();
// Dispose index downloader service.
- if (indexDownloader != null)
- {
- await indexDownloader.StopAsync();
- }
+ indexDownloader?.Stop();
// Dispose connection service.
nodes?.Dispose();
// Dispose chaumian coinjoin client.
@@ -1579,10 +1561,7 @@ namespace WalletWasabi.Tests
{
wallet?.Dispose();
// Dispose index downloader service.
- if (indexDownloader != null)
- {
- await indexDownloader.StopAsync();
- }
+ indexDownloader?.Stop();
// Dispose connection service.
nodes?.Dispose();
// Dispose chaumian coinjoin client.
@@ -2822,10 +2801,7 @@ namespace WalletWasabi.Tests
wallet.NewFilterProcessed -= Wallet_NewFilterProcessed;
wallet?.Dispose();
// Dispose index downloader service.
- if (indexDownloader != null)
- {
- await indexDownloader.StopAsync();
- }
+ indexDownloader?.Stop();
// Dispose connection service.
nodes?.Dispose();
// Dispose chaumian coinjoin client.
@@ -2835,10 +2811,7 @@ namespace WalletWasabi.Tests
}
wallet2?.Dispose();
// Dispose index downloader service.
- if (indexDownloader2 != null)
- {
- await indexDownloader2.StopAsync();
- }
+ indexDownloader2?.Stop();
// Dispose connection service.
nodes2?.Dispose();
// Dispose chaumian coinjoin client.

MODIFY
WalletWasabi/Services/IndexDownloader.cs
WalletWasabi/Services/IndexDownloader.cs
@@ -120,7 +120,7 @@ namespace WalletWasabi.Services
try
{
// If stop was requested return.
- if (IsRunning == false) return;
+ if (!IsRunning) return;
using (await IndexLock.LockAsync())
{
@@ -183,11 +183,14 @@ namespace WalletWasabi.Services
Logger.LogError<IndexDownloader>(ex);
}
finally
+ {
+ if (IsRunning)
{
await Task.Delay(requestInterval); // Ask for new index in every requestInterval.
}
}
}
+ }
finally
{
if (IsStopping)
@@ -207,7 +210,7 @@ namespace WalletWasabi.Services
}
}
- public async Task StopAsync()
+ public void Stop()
{
if (IsRunning)
{
@@ -215,7 +218,7 @@ namespace WalletWasabi.Services
}
while (IsStopping)
{
- await Task.Delay(50);
+ Task.Delay(50).GetAwaiter().GetResult(); // DO NOT MAKE IT ASYNC (.NET Core threading brainfart)
}
WasabiClient?.Dispose();

Add IndexDownloader