Example #1
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public UserController(BlockManager blockManager, PeerToPeerController peerToPeerController, int port)
 {
     _logger               = Log.Logger.ForContext <UserController>();
     _blockManager         = blockManager;
     _peerToPeerController = peerToPeerController;
     _listener             = new HttpListener();
     _listener.Prefixes.Add($"http://localhost:{port}/blocks/");
     _listener.Prefixes.Add($"http://localhost:{port}/mineblock/");
     _listener.Prefixes.Add($"http://localhost:{port}/addpeer/");
     _listener.Prefixes.Add($"http://localhost:{port}/getpeers/");
     Task.Run(RunServerAsync);
 }
Example #2
0
        static void Main(string[] args)
        {
            SetupLogger();
            var genesisBlock = new Block(0, null, null, new DateTime(2018, 7, 31, 5, 48, 6), Encoding.UTF8.GetBytes("Genesis block desu"), "500db07a6ba0b6ce49cf0535be9743a719339366e05f736c675b330c16f36e1e", 1);

            genesisBlock.CheckBlockValidity(null);
            var peerController = new PeerToPeerController(8081);
            var blockManager   = new BlockManager(peerController, genesisBlock);

            using (new UserController(blockManager, peerController, 8080))
            {
                Log.Logger.Information("BlockChain is running...");
                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
            }
        }