public void Mine()
        {
            int division = int.MaxValue / Miners.minerIPs.Count;

            Nonce = 0;
            for (int a = 0; a < Miners.minerIPs.Count; a++)
            {
                if (Miners.minerIPs[a].Equals(TCP.myIP))
                {
                    Nonce = division * a;
                }
            }
            Console.WriteLine("Mine started");
            while (true)
            {
                //if(Nonce%1000 == 0)
                //    Console.WriteLine(Nonce);
                if (ChangeNonce(Nonce))
                {
                    Console.WriteLine("Mine ended");
                    Time = DateTime.Now;
                    Miners.SetMyMinerTrue(this);
                    TCP.SendAllMiners("checkNonce" + Time.ToString() + "$" + BlockID.ToString() + "$" + Nonce.ToString());
                    break;
                }
                else
                {
                    Nonce++;
                }
            }
            Console.WriteLine(
                "Block's hash is -> " + Hash +
                "\nBlock's nonce is -> " + Nonce + "\n" +
                "Found Date is -> " + Time + "\n");
        }
        private static void Interpreter(string message, string ip)
        {
            message = message.Replace("SupplyChain", "Blockchain");
            // received miners list
            if (message.StartsWith("minersList"))
            {
                message = message.Substring(10);
                object ret = JsonDeserialize(message);
                var    obj = Cast(ret, new { list = new List <string>() });
                Miners.minerIPs = obj.list;
                Console.WriteLine("Current miner count: " + Miners.minerIPs.Count);

                for (int a = 0; a < Miners.minerIPs.Count; a++)
                {
                    Miners.miners.Add(new List <KeyValuePair <Block, bool> >());
                }

                if (Miners.minerIPs.Count == 0)
                {
                    BlockChain.GetChain();
                    SendWebServer("addMeNow");
                }

                return;
            }

            // received a new block to add
            if (message.StartsWith("addBlock"))
            {
                Data data = (Data)JsonDeserialize(message.Substring(8));
                BlockChain.ReceiveNewBlock(data);
                return;
            }

            if (message.StartsWith("checkNonce"))
            {
                message = message.Substring(10);
                string[] checkNonceArray = message.Split('$');
                Miners.SetMyMinerTrue(DateTime.Parse(checkNonceArray[0]), long.Parse(checkNonceArray[1]), Int32.Parse(checkNonceArray[2]), ip);
                return;
            }

            if (message.StartsWith("nonceIsTrue"))
            {
                message = message.Substring(11);
                Miners.SetMinersTrue(ip, long.Parse(message));
                return;
            }

            if (message.StartsWith("getChain"))
            {
                Send(ip, "receiveChain" + JsonSerialize(new { chain = BlockChain.GetChain() }));
                return;
            }

            if (message.StartsWith("receiveChain"))
            {
                object ret = JsonDeserialize(message.Substring(12));
                var    obj = Cast(ret, new { chain = new List <Block>() });
                BlockChain.ReceiveChain(obj.chain);
                return;
            }

            if (message.StartsWith("newMinerJoined"))
            {
                message = message.Substring(14);
                Miners.minerIPs.Add(message);
                Miners.miners.Add(new List <KeyValuePair <Block, bool> >());
                if (message == myIP)
                {
                    Console.WriteLine("\n-------Connected to network!-------\n");
                }
                else
                {
                    Console.WriteLine("New miner joined to network -> " + message);
                }
                Console.WriteLine("Current miner count: " + Miners.minerIPs.Count);
                return;
            }

            if (message.StartsWith("verify"))
            {
                message = message.Substring(6);
                Product product = BlockChain.GetProductInfo(long.Parse(message));
                SendWebServer("verifyReturn" + JsonSerialize(product));
                return;
            }

            if (message.StartsWith("block"))
            {
                message = message.Substring(5);
                Block takenBlock = (Block)JsonDeserialize(message);

                // wait until the block is inserted into chain
                bool wait = true;
                while (wait)
                {
                    List <Block> chain = BlockChain.GetChain();

                    try {
                        wait = !chain.Exists(b => b.BlockID.Equals(takenBlock.BlockID));
                    }
                    catch { }
                }

                Block currentBlock = BlockChain.GetBlock(takenBlock.BlockID);

                // change time earlier if taken one is earlier
                if (currentBlock.Time.CompareTo(takenBlock.Time) > 0)
                {
                    currentBlock.Time  = takenBlock.Time;
                    currentBlock.Nonce = takenBlock.Nonce;
                    currentBlock.Hash  = currentBlock.CalculateHash();
                }

                // change smaller nonce if the found dates equal
                if (currentBlock.Time.CompareTo(takenBlock.Time) == 0)
                {
                    currentBlock.Nonce = Math.Min(takenBlock.Nonce, currentBlock.Nonce);
                }
            }
        }