예제 #1
0
        static async Task Main(string[] args)
        {
            var config = Knuth.Config.Settings.GetDefault(NetworkType.Mainnet);

            config.Node.DsProofsEnabled = true;
            using (var node = new Knuth.Node(config)) {
                await node.LaunchAsync();

                Console.WriteLine("Knuth node has been launched.");

                node.SubscribeDsProofNotifications((err, dsp) => {
                    Console.WriteLine($"ATTENTION: a Double-Spend attempt has been received!");
                    return(true);
                });

                var height = await node.Chain.GetLastHeightAsync();

                Console.WriteLine($"Current height in local copy: {height.Result}");

                if (node.Chain.IsStale)
                {
                    Console.WriteLine("Knuth is doing IBD.");
                }

                await DiscoverThePowerOfKnuth(node);
            }
        }
예제 #2
0
        static async Task Main(string[] args)
        {
            const int blockHeight = 170;

            var buildConfig = Knuth.LibConfig.Get();

            Console.WriteLine($"LogLibrary:          {buildConfig.LogLibrary}");
            Console.WriteLine($"UseLibmdbx:          {buildConfig.UseLibmdbx}");
            Console.WriteLine($"Version:             {buildConfig.Version}");
            Console.WriteLine($"Microarchitecture:   {buildConfig.Microarchitecture}");
            Console.WriteLine($"MicroarchitectureId: {buildConfig.MicroarchitectureId}");
            Console.WriteLine($"Currency:            {buildConfig.Currency}");
            Console.WriteLine($"Mempool:             {buildConfig.Mempool}");
            Console.WriteLine($"DbMode:              {buildConfig.DbMode}");
            Console.WriteLine($"DbReadonly:          {buildConfig.DbReadonly}");
            Console.WriteLine($"DebugMode:           {buildConfig.DebugMode}");

            var config = Knuth.Config.Settings.GetDefault(NetworkType.Mainnet);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("DB Directory: {0}", config.Database.Directory);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Launching node...");

            using (var node = new Knuth.Node(config, false)) {
                var res = await node.LaunchAsync();

                Console.WriteLine(res);
                Console.WriteLine("Knuth node has been launched.");

                await WaitUntilBlock(node.Chain, blockHeight);

                var heightRes = await node.Chain.GetLastHeightAsync();

                Console.WriteLine($"Current height in local copy: {heightRes.Result}");

                for (ulong i = 0; i < blockHeight; ++i)
                {
                    var blockRes = await node.Chain.GetBlockByHeightAsync(i);

                    var data   = blockRes.Result.BlockData.ToData(true);
                    var hexStr = Binary.ByteArrayToHexString(data);
                    Console.WriteLine(hexStr);
                }
            }
        }
예제 #3
0
        static async Task Main(string[] args)
        {
            Console.CancelKeyPress += OnSigInterrupt;

            var config = Knuth.Config.Settings.GetDefault(NetworkType.Mainnet);

            config.Database.DbMaxSize /= 1024;
            config.Network.Threads     = 1;
            config.Chain.Cores         = 1;
            // Console.WriteLine($"Config: {JsonSerializer.Serialize(config)}");

            using (var node = new Knuth.Node(config, true)) {
                Console.WriteLine("Lauching Knuth node...");
                var res = await node.LaunchAsync();

                if (res != ErrorCode.Success)
                {
                    Console.WriteLine("Error launching the node...");
                    return;
                }

                running_ = true;
                Console.WriteLine("Knuth node has been launched.");

                var height = await node.Chain.GetLastHeightAsync();

                Console.WriteLine($"Current height in local copy: {height.Result}");

                if (await ComeBackAfterTheBCHHardFork(node))
                {
                    Console.WriteLine("Bitcoin Cash has been created!");
                }
                Console.WriteLine("Closing the node...");
            }
            Console.WriteLine("Good bye!");
        }