Пример #1
0
        public void Run(string[] args)
        {
            CliParser.IsValidArgs(args);
            switch (args[0])
            {
            case "addblock":
                var addblock = CliParser.Parse_addblock(args);
                if (!string.IsNullOrWhiteSpace(addblock.ToString()))
                {
                    AddBlock(addblock.ToString());
                }
                else
                {
                    Console.WriteLine("区块数据不能为空...");
                }
                break;

            case "printchain":
                var print = CliParser.Parse_printchain(args);
                if (Convert.ToBoolean(print))
                {
                    PrintBC();
                }
                break;

            case "createblockchain":
                var createbc = CliParser.Parse_createblockchain(args);
                if (!string.IsNullOrWhiteSpace(createbc.ToString()))
                {
                    CreateGenesisBlockchain(createbc.ToString());
                }
                else
                {
                    //创建默认创世区块
                    CreateGenesisBlockchain("Genesis data...");
                }
                break;

            default:
                CliParser.PrintUsage();
                break;
            }
        }
Пример #2
0
        public void Run(string[] args)
        {
            CliParser.IsValidArgs(args);
            switch (args[0])
            {
            case "send":
                var addblock = CliParser.Parse_addblock(args);
                if (null != addblock)
                {
                    //AddBlock(addblock);
                }
                else
                {
                    CliParser.PrintUsage();
                }
                break;

            case "printchain":
                var print = CliParser.Parse_printchain(args);
                if (Convert.ToBoolean(print))
                {
                    PrintBC();
                }
                break;

            case "createblockchain":
                var createbc = CliParser.Parse_createblockchain(args);
                if (!string.IsNullOrWhiteSpace(createbc))
                {
                    CreateGenesisBlockchain(createbc);
                }
                else
                {
                    Console.WriteLine("地址不能为空...");
                }
                break;

            default:
                CliParser.PrintUsage();
                break;
            }
        }