<commit_before>﻿using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NBitcoin;
using NTumbleBit.Common;
using System.IO;
using NTumbleBit.Client.Tumbler.Services;
using NTumbleBit.Client.Tumbler;
using System.Threading;
using NTumbleBit.Common.Logging;
using System.Text;
using NBitcoin.RPC;
using CommandLine;
using System.Reflection;
using NTumbleBit.ClassicTumbler;

namespace NTumbleBit.CLI
{
	public partial class Program
	{
		public static void Main(string[] args)
		{
			new Program().Run(args);
		}
		public void Run(string[] args)
		{
			Logs.Configure(new FuncLoggerFactory(i => new ConsoleLogger(i, (a, b) => true, false)));
			BroadcasterToken = new CancellationTokenSource();
			MixingToken = new CancellationTokenSource();
			DBreezeRepository dbreeze = null;
			try
			{
				var config = new TumblerClientConfiguration();
				config.LoadArgs(args);
				Network = config.Network;

				ClassicTumblerParameters toConfirm;
				var runtime = TumblerClientRuntime.FromConfiguration(config, out toConfirm);
				if(toConfirm != null)
				{
					if(!PromptConfirmation(toConfirm))
					{
						runtime.Confirm(toConfirm);
						Logs.Main.LogInformation("New tumbler parameters refused");
						return;
					}
				}

				Tracker = runtime.Tracker;
				Services = runtime.Services;
				DestinationWallet = runtime.DestinationWallet;

				var broadcaster = runtime.CreateBroadcasterJob();
				broadcaster.Start(BroadcasterToken.Token);
				Logs.Main.LogInformation("BroadcasterJob started");

				if(!config.OnlyMonitor)
				{
					var client = new TumblerClient(Network, config.TumblerServer);
					TumblerParameters = runtime.TumblerParameters;
					var stateMachine = runtime.CreateStateMachineJob();
					stateMachine.Start(MixingToken.Token);
					Logs.Main.LogInformation("State machines started");
				}


				StartInteractive();
			}
			catch(ConfigException ex)
			{
				if(!string.IsNullOrEmpty(ex.Message))
					Logs.Configuration.LogError(ex.Message);
			}
			catch(Exception ex)
			{
				Logs.Configuration.LogError(ex.Message);
				Logs.Configuration.LogDebug(ex.StackTrace);
			}
			finally
			{
				if(!MixingToken.IsCancellationRequested)
					MixingToken.Cancel();
				if(!BroadcasterToken.IsCancellationRequested)
					BroadcasterToken.Cancel();
				dbreeze?.Dispose();
			}
		}

		private bool PromptConfirmation(ClassicTumblerParameters toConfirm)
		{
			Console.WriteLine("Do you confirm the following tumbler settings? (type 'yes' to accept)");
			Console.WriteLine("------");
			Console.WriteLine(Serializer.ToString(toConfirm));
			Console.WriteLine("--");
			Console.WriteLine("Tumbler Fee: " + toConfirm.Fee.ToString());
			Console.WriteLine("Denomination: " + toConfirm.Denomination.ToString());
			var periods = toConfirm.CycleGenerator.FirstCycle.GetPeriods();
			Console.WriteLine("Total cycle length: " + (periods.Total.End - periods.Total.Start) + " blocks");
			Console.WriteLine("------");
			var response = Console.ReadLine();
			return response.Equals("yes", StringComparison.OrdinalIgnoreCase);
		}
	}
}<commit_msg>fix parameter confirmation<commit_after>﻿using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NBitcoin;
using NTumbleBit.Common;
using System.IO;
using NTumbleBit.Client.Tumbler.Services;
using NTumbleBit.Client.Tumbler;
using System.Threading;
using NTumbleBit.Common.Logging;
using System.Text;
using NBitcoin.RPC;
using CommandLine;
using System.Reflection;
using NTumbleBit.ClassicTumbler;

namespace NTumbleBit.CLI
{
	public partial class Program
	{
		public static void Main(string[] args)
		{
			new Program().Run(args);
		}
		public void Run(string[] args)
		{
			Logs.Configure(new FuncLoggerFactory(i => new ConsoleLogger(i, (a, b) => true, false)));
			BroadcasterToken = new CancellationTokenSource();
			MixingToken = new CancellationTokenSource();
			DBreezeRepository dbreeze = null;
			try
			{
				var config = new TumblerClientConfiguration();
				config.LoadArgs(args);
				Network = config.Network;

				ClassicTumblerParameters toConfirm;
				var runtime = TumblerClientRuntime.FromConfiguration(config, out toConfirm);
				if(toConfirm != null)
				{
					if(!PromptConfirmation(toConfirm))
					{
						Logs.Main.LogInformation("New tumbler parameters refused");
						return;
					}
					runtime.Confirm(toConfirm);
				}

				Tracker = runtime.Tracker;
				Services = runtime.Services;
				DestinationWallet = runtime.DestinationWallet;

				var broadcaster = runtime.CreateBroadcasterJob();
				broadcaster.Start(BroadcasterToken.Token);
				Logs.Main.LogInformation("BroadcasterJob started");

				if(!config.OnlyMonitor)
				{
					var client = new TumblerClient(Network, config.TumblerServer);
					TumblerParameters = runtime.TumblerParameters;
					var stateMachine = runtime.CreateStateMachineJob();
					stateMachine.Start(MixingToken.Token);
					Logs.Main.LogInformation("State machines started");
				}


				StartInteractive();
			}
			catch(ConfigException ex)
			{
				if(!string.IsNullOrEmpty(ex.Message))
					Logs.Configuration.LogError(ex.Message);
			}
			catch(Exception ex)
			{
				Logs.Configuration.LogError(ex.Message);
				Logs.Configuration.LogDebug(ex.StackTrace);
			}
			finally
			{
				if(!MixingToken.IsCancellationRequested)
					MixingToken.Cancel();
				if(!BroadcasterToken.IsCancellationRequested)
					BroadcasterToken.Cancel();
				dbreeze?.Dispose();
			}
		}

		private bool PromptConfirmation(ClassicTumblerParameters toConfirm)
		{
			Console.WriteLine("Do you confirm the following tumbler settings? (type 'yes' to accept)");
			Console.WriteLine("------");
			Console.WriteLine(Serializer.ToString(toConfirm));
			Console.WriteLine("--");
			Console.WriteLine("Tumbler Fee: " + toConfirm.Fee.ToString());
			Console.WriteLine("Denomination: " + toConfirm.Denomination.ToString());
			var periods = toConfirm.CycleGenerator.FirstCycle.GetPeriods();
			Console.WriteLine("Total cycle length: " + (periods.Total.End - periods.Total.Start) + " blocks");
			Console.WriteLine("------");
			Console.WriteLine("Do you confirm the following tumbler settings? (type 'yes' to accept)");
			var response = Console.ReadLine();
			return response.Equals("yes", StringComparison.OrdinalIgnoreCase);
		}
	}
}
{'fraction_non_alphanumeric': 0.11711155685850949, 'fraction_numerical': 0.0, 'mean_word_length': 4.240097008892482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1649201', 'n_tokens_mistral': 2313, 'n_tokens_neox': 1907, 'n_words': 363}