示例#1
0
        static async Task Main(string[] args)
        {
            Logger.InitializeDefaults();

            Logger.LogInfo("Parsing arguments...");
            ParseArgs(args, out Command command, out NetworkCredential rpcCred);

            var rpcConf = new RPCCredentialString
            {
                UserPassword = rpcCred
            };
            var client = new RPCClient(rpcConf, Network.Main);

            Logger.LogInfo("Checking Bitcoin Knots sync status...");

            var bci = await client.GetBlockchainInfoAsync();

            var missingBlocks = bci.Headers - bci.Blocks;

            if (missingBlocks != 0)
            {
                throw new InvalidOperationException($"Knots is not synchronized. Blocks missing: {missingBlocks}.");
            }

            Logger.LogInfo($"Bitcoin Knots is synchronized. Current height: {bci.Blocks}.");

            using (BenchmarkLogger.Measure(operationName: $"{command} Command"))
            {
                if (command == Command.Resync)
                {
                    var scanner = new Scanner(client);
                    await scanner.ScanAsync(rescan : true);
                }
                else if (command == Command.Sync)
                {
                    var scanner = new Scanner(client);
                    await scanner.ScanAsync(rescan : false);
                }
                else if (command == Command.Check)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var checker            = new Checker(loadedScannerFiles);
                    checker.Check();
                }
                else if (command == Command.MonthlyVolumes)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles, client);
                    stat.CalculateMonthlyVolumes();
                }
                else if (command == Command.FreshBitcoins)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles, client);
                    stat.CalculateFreshBitcoins();
                }
                else if (command == Command.NeverMixed)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles, client);
                    stat.CalculateNeverMixed();
                }
                else if (command == Command.CoinJoinEquality)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles, client);
                    stat.CalculateEquality();
                }
                else if (command == Command.CoinJoinIncome)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles, client);
                    stat.CalculateIncome();
                }
                else if (command == Command.PostMixConsolidation)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles, client);
                    stat.CalculatePostMixConsolidation();
                }
                else if (command == Command.SmallerThanMinimum)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles, client);
                    stat.CalculateSmallerThanMinimumWasabiInputs();
                }
                else if (command == Command.MonthlyEqualVolumes)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles, client);
                    stat.CalculateMonthlyEqualVolumes();
                }
            }

            Console.WriteLine();
            Console.WriteLine("Press a button to exit...");
            Console.ReadKey();
        }
示例#2
0
        private static async Task Main(string[] args)
        {
            Logger.InitializeDefaults();

            Logger.LogInfo("Parsing arguments...");
            ParseArgs(args, out Command command, out NetworkCredential rpcCred);

            var rpcConf = new RPCCredentialString
            {
                UserPassword = rpcCred
            };
            var client = new RPCClient(rpcConf, Network.Main);

            using (BenchmarkLogger.Measure(operationName: $"{command} Command"))
            {
                if (command == Command.Resync)
                {
                    var scanner = new Scanner(client);
                    await scanner.ScanAsync(rescan : true);
                }
                else if (command == Command.Sync)
                {
                    var scanner = new Scanner(client);
                    await scanner.ScanAsync(rescan : false);
                }
                else if (command == Command.Check)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var checker            = new Checker(loadedScannerFiles);
                    checker.Check();
                }
                else if (command == Command.MonthlyVolumes)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateMonthlyVolumes();
                }
                else if (command == Command.FreshBitcoins)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateFreshBitcoins();
                }
                else if (command == Command.FreshBitcoinAmounts)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateFreshBitcoinAmounts();
                }
                else if (command == Command.FreshBitcoinsDaily)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateFreshBitcoinsDaily();
                }
                else if (command == Command.NeverMixed)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateNeverMixed(client);
                }
                else if (command == Command.CoinJoinEquality)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateEquality();
                }
                else if (command == Command.CoinJoinIncome)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateIncome();
                }
                else if (command == Command.PostMixConsolidation)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculatePostMixConsolidation();
                }
                else if (command == Command.SmallerThanMinimum)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateSmallerThanMinimumWasabiInputs();
                }
                else if (command == Command.MonthlyEqualVolumes)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateMonthlyEqualVolumes();
                }
                else if (command == Command.AverageUserCount)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateMonthlyAverageMonthlyUserCounts();
                }
                else if (command == Command.AverageNetworkFeePaidByUserPerCoinjoin)
                {
                    var loadedScannerFiles = Scanner.Load();
                    var stat = new Statista(loadedScannerFiles);
                    stat.CalculateMonthlyNetworkFeePaidByUserPerCoinjoin();
                }
            }

            Console.WriteLine();
            Console.WriteLine("Press a button to exit...");
            Console.ReadKey();
        }