Exemple #1
0
        protected override void Parse(EndianBinaryReader r)
        {
            Position       = CoordInt.Read(r);
            TypeState      = r.ReadByte();
            PitchDirection = r.ReadByte();
            BlockType      = (BlockID)ReadVarInt(r);

#if DEBUG
            if (BlockType.ToString() == ((int)BlockType).ToString())
            {
                throw new NotImplementedException(BlockType.ToString());
            }
#endif
        }
        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");
        }
        /// <summary>
        /// Calculate block's hash with Time, ParantID, BlockID and Product object
        /// </summary>
        /// <returns>Hash of block</returns>
        public string CalculateHash()
        {
            SHA256 sHA256 = SHA256.Create();

            byte[] input  = Encoding.ASCII.GetBytes(BlockID.ToString() + Data.ToString() + Nonce.ToString());
            byte[] output = sHA256.ComputeHash(input);
            return(Convert.ToBase64String(output));
        }
        public void BlockID()
        {
            var blockID  = new BlockID("foofoofoofoo");
            var actual   = blockID.ToString();
            var expected = $"{blockID.Node} | {blockID.Round} | 666F6F666F6F";

            Assert.Equal(expected, actual);
        }
        public void InvalidBlockID()
        {
            var blockID  = new BlockID("");
            var actual   = blockID.ToString();
            var expected = $"{blockID.Node} | {blockID.Round}";

            Assert.Equal(expected, actual);
        }
Exemple #6
0
        protected override void Parse(EndianBinaryReader r)
        {
            Position = CoordInt.Read(r);
            TypeState = r.ReadByte();
            PitchDirection = r.ReadByte();
            BlockType = (BlockID)ReadVarInt(r);

            #if DEBUGPACKET
            if (BlockType.ToString() == ((int)BlockType).ToString())
                throw new NotImplementedException(BlockType.ToString());
            #endif
        }
Exemple #7
0
 public override string ToString()
 {
     return(BlockID.ToString() + ", " + Offset.ToString() + ", " + ExtraOffset.ToString());
 }
Exemple #8
0
        }                                                                            //byte offset


        public override string ToString()
        {
            return(BlockID.ToString() + ", " + ItemOffset.ToString() + ", " + Unk2.ToString());
        }