Example #1
0
        public Node(ITransactionVerifier transactionVerifier, string overrideFilelocation = "", bool overideBlockchainSave = false, IPAddress master = null, IDotcoinServer dotcoinServer = null)
        {
            //if you dont pass in a master address it assumes
            //there is no master and takes over that roll
            IPAddress myIp = null;

            var hostname = Dns.GetHostName();

            Console.WriteLine(string.Format("Nodes hostname is: {0}", hostname));

            var ips = Dns.GetHostAddresses(hostname);

            foreach (var ip in ips)
            {
                //TODO make this a correct public ip
                myIp           = ip;
                _masterAddress = ip;
                Console.WriteLine(ip.ToString());
            }

            if (myIp == null)
            {
                throw new Exception("Error getting ip");
            }

            if (master == null)
            {
                _masterAddress = myIp;
            }

            if (dotcoinServer == null) //default server for the chain
            {
                dotcoinServer = new DotcoinTCPServer();
            }

            _network = new DotcoinNetwork(myIp, _masterAddress, dotcoinServer);

            _transactionVerifier = transactionVerifier;

            _overideBlockchainSave = overideBlockchainSave;

            if (overrideFilelocation == "")
            {
                overrideFilelocation = "dotcoin.chain";
            }

            _blockChain = new BlockChain(overrideFilelocation);
        }
        public DotcoinNetworkTests()
        {
            createIpFile();

            _testNetwork = new DotcoinNetwork(IPAddress.Any, IPAddress.Any, new DotcoinTestServer(), TEST_NETWORK_IP_FILE);
        }