示例#1
0
文件: Core.cs 项目: aal89/sharpcoin
        public Core(string[] args)
        {
            Log.NewLine("sharpcoin (core) v0.1.1 -- by aal89");

            // Configure the ip address to bind on
            if (args.Length == 1 && IPAddress.Parse(args[0]) != null)
            {
                IpAddr.Set(args[0]);
            }
            Log.NewLine($"Attempting to bind tcp servers to address: {IpAddr.Mine()}.");

            // Load blockchain
            Log.NewLine($"Initializing blockchain.");
            Blockchain = new Blockchain(new Logger("Blockchain"));

            // Setup event listeners
            Log.Line("Setting up event listeners...");
            Blockchain.BlockAdded             += Blockchain_BlockAdded;
            Blockchain.QueuedTransactionAdded += Blockchain_QueuedTransactionAdded;
            Log.Append("Done.");

            // Setup api
            Log.Line($"Setting up client management...");
            _ = new ClientManager(this, new Logger("ClientManager"));
            Log.Append("Done.");

            // Setup mine operator
            Log.Line($"Setting up mine operator...");
            Operator = new Operator(Blockchain, new Logger("Miner"));
            Log.Append("Done.");

            // Setup peer manager (server&client)
            Log.NewLine($"Setting up peer manager.");
            PeerManager = new PeerManager(this, new Logger("PeerManager"));
        }