public async Task ExecuteAsync(CancellationToken cancellationToken) { Logger.InitializeDefaults(Path.Combine(Global.DataDir, "Logs.txt")); Logger.LogStarting("Wasabi Backend"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; var configFilePath = Path.Combine(Global.DataDir, "Config.json"); var config = new Config(configFilePath); await config.LoadOrCreateDefaultFileAsync(); Logger.LogInfo <Config>("Config is successfully initialized."); var roundConfigFilePath = Path.Combine(Global.DataDir, "CcjRoundConfig.json"); var roundConfig = new CcjRoundConfig(roundConfigFilePath); await roundConfig.LoadOrCreateDefaultFileAsync(); Logger.LogInfo <CcjRoundConfig>("RoundConfig is successfully initialized."); string host = config.GetBitcoinCoreRpcEndPoint().ToString(config.Network.RPCPort); var rpc = new RPCClient( authenticationString: config.BitcoinRpcConnectionString, hostOrUri: host, network: config.Network); await Global.InitializeAsync(config, roundConfig, rpc); try { Directory.CreateDirectory(UnversionedWebBuilder.UnversionedFolder); UnversionedWebBuilder.CreateDownloadTextWithVersionHtml(); UnversionedWebBuilder.CloneAndUpdateOnionIndexHtml(); if (File.Exists(Global.Coordinator.CoinJoinsFilePath)) { string[] allLines = File.ReadAllLines(Global.Coordinator.CoinJoinsFilePath); Last5CoinJoins = allLines.TakeLast(5).Reverse().ToList(); UnversionedWebBuilder.UpdateCoinJoinsHtml(Last5CoinJoins); } Global.Coordinator.CoinJoinBroadcasted += Coordinator_CoinJoinBroadcasted; } catch (Exception ex) { Logger.LogWarning(ex, nameof(Program)); } }
public async Task ExecuteAsync(CancellationToken cancellationToken) { Logger.InitializeDefaults(Path.Combine(Global.DataDir, "Logs.txt")); Logger.LogSoftwareStarted("Wasabi Backend"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; var configFilePath = Path.Combine(Global.DataDir, "Config.json"); var config = new Config(configFilePath); config.LoadOrCreateDefaultFile(); Logger.LogInfo("Config is successfully initialized."); var roundConfigFilePath = Path.Combine(Global.DataDir, "CcjRoundConfig.json"); var roundConfig = new CoordinatorRoundConfig(roundConfigFilePath); roundConfig.LoadOrCreateDefaultFile(); Logger.LogInfo("RoundConfig is successfully initialized."); string host = config.GetBitcoinCoreRpcEndPoint().ToString(config.Network.RPCPort); var rpc = new RPCClient( authenticationString: config.BitcoinRpcConnectionString, hostOrUri: host, network: config.Network); var cachedRpc = new CachedRpcClient(rpc, Cache); await Global.InitializeAsync(config, roundConfig, cachedRpc, cancellationToken); try { await WebsiteTorifier.CloneAndUpdateOnionIndexHtmlAsync(); } catch (Exception ex) { Logger.LogWarning(ex); } }