Downsize the `InitializeNoWalletAsync`
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -156,19 +156,7 @@ namespace WalletWasabi.Gui
Logger.LogInfo("System Awake Checker is not available on this platform.");
}
- if (Config.UseTor && Network != Network.RegTest)
- {
- using (BenchmarkLogger.Measure(operationName: "TorProcessManager.Start"))
- {
- TorManager = new TorProcessManager(TorSettings);
- await TorManager.StartAsync(cancel).ConfigureAwait(false);
- }
-
- Tor.Http.TorHttpClient torHttpClient = BackendHttpClientFactory.NewTorHttpClient(Mode.DefaultCircuit);
- HostedServices.Register<TorMonitor>(new TorMonitor(period: TimeSpan.FromSeconds(3), fallbackBackendUri: Config.GetFallbackBackendUri(), torHttpClient, TorManager), nameof(TorMonitor));
- }
-
- Logger.LogInfo($"{nameof(TorProcessManager)} is initialized.");
+ await StartTorProcessManagerAsync(cancel).ConfigureAwait(false);
try
{
@@ -202,6 +190,24 @@ namespace WalletWasabi.Gui
TransactionBroadcaster.Initialize(HostedServices.Get<P2pNetwork>().Nodes, BitcoinCoreNode?.RpcClient);
CoinJoinProcessor = new CoinJoinProcessor(Network, Synchronizer, WalletManager, BitcoinCoreNode?.RpcClient);
+ await StartRpcServerAsync(terminateService, cancel).ConfigureAwait(false);
+
+ var blockProvider = new CachedBlockProvider(
+ new SmartBlockProvider(
+ new P2pBlockProvider(HostedServices.Get<P2pNetwork>().Nodes, BitcoinCoreNode, BackendHttpClientFactory, Config.ServiceConfiguration, Network),
+ Cache),
+ BitcoinStore.BlockRepository);
+
+ WalletManager.RegisterServices(BitcoinStore, Synchronizer, Config.ServiceConfiguration, HostedServices.Get<HybridFeeProvider>(), blockProvider);
+ }
+ finally
+ {
+ InitializationCompleted.TrySetResult(true);
+ }
+ }
+
+ private async Task StartRpcServerAsync(TerminateService terminateService, CancellationToken cancel)
+ {
var jsonRpcServerConfig = new JsonRpcServerConfiguration(Config);
if (jsonRpcServerConfig.IsEnabled)
{
@@ -216,18 +222,21 @@ namespace WalletWasabi.Gui
RpcServer = null;
}
}
-
- var blockProvider = new CachedBlockProvider(
- new SmartBlockProvider(
- new P2pBlockProvider(HostedServices.Get<P2pNetwork>().Nodes, BitcoinCoreNode, BackendHttpClientFactory, Config.ServiceConfiguration, Network),
- Cache),
- BitcoinStore.BlockRepository);
-
- WalletManager.RegisterServices(BitcoinStore, Synchronizer, Config.ServiceConfiguration, HostedServices.Get<HybridFeeProvider>(), blockProvider);
}
- finally
+
+ private async Task StartTorProcessManagerAsync(CancellationToken cancel)
{
- InitializationCompleted.TrySetResult(true);
+ if (Config.UseTor && Network != Network.RegTest)
+ {
+ using (BenchmarkLogger.Measure(operationName: "TorProcessManager.Start"))
+ {
+ TorManager = new TorProcessManager(TorSettings);
+ await TorManager.StartAsync(cancel).ConfigureAwait(false);
+ Logger.LogInfo($"{nameof(TorProcessManager)} is initialized.");
+ }
+
+ Tor.Http.TorHttpClient torHttpClient = BackendHttpClientFactory.NewTorHttpClient(Mode.DefaultCircuit);
+ HostedServices.Register<TorMonitor>(new TorMonitor(period: TimeSpan.FromSeconds(3), fallbackBackendUri: Config.GetFallbackBackendUri(), torHttpClient, TorManager), nameof(TorMonitor));
}
}

Downsize the `InitializeNoWalletAsync`