static void Main(string[] args) { //Console.OutputEncoding = Encoding.UTF8; //if(args.Length == 0) //{ //args = new string[1]; //Random rnd = new Random(); //args[0] = @"http://*****:*****@"http://localhost:44312"; //} //baseAddress = args[0]; //if (!baseAddress.EndsWith("/")) baseAddress += "/"; // // Start OWIN host baseAddress = "http://localhost:8080/"; using (WebApp.Start <Startup>(url: baseAddress)) { Console.WriteLine("This CSharpChain node is running on " + baseAddress); Console.WriteLine("Nhận 'trogiup' nếu bạn không chắc phải làm gì ;)"); blockchainServices = new BlockchainServices(); nodeServices = new NodeServices(blockchainServices.Blockchain); string commandLine; do { ShowCommandLine(); commandLine = Console.ReadLine().ToLower(); commandLine += " "; var command = commandLine.Split(' '); switch (command[0]) { case "quit": case "q": commandLine = "q"; break; case "trogiup": case "?": CommandHelp(); break; case "node-add": case "na": // if param1 is numeric then translate to localhost port //if (command[1].All(char.IsDigit)) command[1] = "http://localhost:" + command[1]; //CommandNodeAdd(command[1]); CommandNodeAdd("http://localhost:" + command[1].ToString()); break; case "node-remove": case "nr": // if param1 is numeric then translate to localhost port //if (command[1].All(char.IsDigit)) command[1] = "http://localhost:" + command[1]; //CommandNodeRemove(command[1]); CommandNodeRemove("http://localhost:" + command[1].ToString()); break; case "nodes-list": case "nl": CommandListNodes(nodeServices.Nodes); break; case "transactions-add": case "ta": CommandTransactionsAdd(command[1], command[2], command[3], command[4]); break; case "transactions-pending": case "tp": CommandListPendingTransactions(blockchainServices.Blockchain.PendingTransactions); break; case "blockchain-mine": case "bm": CommandBlockchainMine(command[1]); break; case "bv": case "blockchain-valid": CommandBlockchainValidity(); break; case "blockchain-length": case "bl": CommandBlockchainLength(); break; case "block": case "b": CommandBlock(int.Parse(command[1])); break; case "balance-get": case "bal": CommandBalance(command[1]); break; case "blockchain-update": case "update": case "bu": CommandBlockchainUpdate(); break; default: Console.WriteLine("Ups! I don't understand..."); Console.WriteLine(""); break; } } while (commandLine != "q"); } }
static void Main(string[] args) { baseAddress = args[0]; if (!baseAddress.EndsWith("/")) { baseAddress += "/"; } // Start OWIN host using (WebApp.Start <Startup>(url: baseAddress)) { Console.WriteLine(""); Console.WriteLine("CSharpChain Blockchain // [email protected] // www.mauer.si"); Console.WriteLine("----------------------------------------"); Console.WriteLine("This CSharpChain node is running on " + baseAddress); Console.WriteLine("Type 'help' if you are not sure what to do ;)"); blockchainServices = new BlockchainServices(); nodeServices = new NodeServices(blockchainServices.Blockchain); string commandLine; do { ShowCommandLine(); commandLine = Console.ReadLine().ToLower(); commandLine += " "; var command = commandLine.Split(' '); switch (command[0]) { case "quit": case "q": commandLine = "q"; break; case "help": case "?": CommandHelp(); break; case "node-add": case "na": // if param1 is numeric then translate to localhost port if (command[1].All(char.IsDigit)) { command[1] = "http://localhost:" + command[1]; } CommandNodeAdd(command[1]); break; case "node-remove": case "nr": // if param1 is numeric then translate to localhost port if (command[1].All(char.IsDigit)) { command[1] = "http://localhost:" + command[1]; } CommandNodeRemove(command[1]); break; case "nodes-list": case "nl": CommandListNodes(nodeServices.Nodes); break; case "transactions-add": case "ta": CommandTransactionsAdd(command[1], command[2], command[3], command[4]); break; case "transactions-pending": case "tp": CommandListPendingTransactions(blockchainServices.Blockchain.PendingTransactions); break; case "blockchain-mine": case "bm": CommandBlockchainMine(command[1]); break; case "bv": case "blockchain-valid": CommandBlockchainValidity(); break; case "blockchain-length": case "bl": CommandBlockchainLength(); break; case "block": case "b": CommandBlock(int.Parse(command[1])); break; case "balance-get": case "bal": CommandBalance(command[1]); break; case "blockchain-update": case "update": case "bu": CommandBlockchainUpdate(); break; default: Console.WriteLine("Ups! I don't understand..."); Console.WriteLine(""); break; } } while (commandLine != "q"); } }