示例#1
0
        public WorkBlock(JObject obj)
        {
            strMidstate = obj["midstate"].ToString();
            strData     = obj["data"].ToString();
            strHash1    = obj["hash1"].ToString();
            strTarget   = obj["target"].ToString();

            //strMidstate = "339a90bcf0bf58637daccc90a8ca591ee9d8c8c3c803014f3687b1961bf91947";
            //strData = "000000010000000000000000000000000000000000000000000000000000000000000000fdeda33bb2127b7a3e2cc77a618f7667c31bc87f32518a88aab89f3a4a5e1e4b495fab291d00ffff7c2bac1d000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000";
            //strTarget = "0000000000000000000000000000000000000000000000000000ffff00000000";
            // 2,083,236,893

            //strData = "000000022a34cf18f3e954a376d84bfb9665b4f9602e7fc0a90a934b9aa31b1abf7b9d63ade27f84f9d067e70428d2e72d58405fdb42626fe166e0d245efaae46390dbd9532a27ed1c011b0d6bb20500000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000";
            //strTarget = "000000000000000000000000000000000000000000000000000d1b0100000000";

            midstate = Utils.HexStringToByteArray(strMidstate);
            data     = Utils.HexStringToByteArray(strData);
            hash1    = Utils.HexStringToByteArray(strHash1);
            target   = Utils.HexStringToByteArray(strTarget);


            data64 = new byte[64];
            Buffer.BlockCopy(data, 64, data64, 0, 64);
            //Utils.ByteSwapIntegers(target);

            mHashMan = new HashManager();
        }
示例#2
0
        public WorkBlock(JObject obj)
        {
            strMidstate = obj["midstate"].ToString();
            strData = obj["data"].ToString();
            strHash1 = obj["hash1"].ToString();
            strTarget = obj["target"].ToString();

            //strMidstate = "339a90bcf0bf58637daccc90a8ca591ee9d8c8c3c803014f3687b1961bf91947";
            //strData = "000000010000000000000000000000000000000000000000000000000000000000000000fdeda33bb2127b7a3e2cc77a618f7667c31bc87f32518a88aab89f3a4a5e1e4b495fab291d00ffff7c2bac1d000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000";
            //strTarget = "0000000000000000000000000000000000000000000000000000ffff00000000";
            // 2,083,236,893

            //strData = "000000022a34cf18f3e954a376d84bfb9665b4f9602e7fc0a90a934b9aa31b1abf7b9d63ade27f84f9d067e70428d2e72d58405fdb42626fe166e0d245efaae46390dbd9532a27ed1c011b0d6bb20500000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000";
            //strTarget = "000000000000000000000000000000000000000000000000000d1b0100000000";

            midstate = Utils.HexStringToByteArray(strMidstate);
            data = Utils.HexStringToByteArray(strData);
            hash1 = Utils.HexStringToByteArray(strHash1);
            target = Utils.HexStringToByteArray(strTarget);

            data64 = new byte[64];
            Buffer.BlockCopy(data, 64, data64, 0, 64);
            //Utils.ByteSwapIntegers(target);

            mHashMan = new HashManager();
        }
示例#3
0
        public void Initialize(ulong serverDiff)
        {
            if (serverDiff == 0)
            {
                uint diff      = Utils.HexStringToUInt(mDifficulty);
                int  diffBytes = ((int)diff >> 24) & 0x000000FF;

                strTarget = "";
                for (int i = 0; i < diffBytes - 3; i++)
                {
                    strTarget += "00";
                }
                strTarget += string.Format("{0:X2}", (byte)diff);
                strTarget += string.Format("{0:X2}", (byte)((int)diff >> 8));
                strTarget += string.Format("{0:X2}", (byte)((int)diff >> 16));
                for (int i = diffBytes; i < 32; i++)
                {
                    strTarget += "00";
                }
            }
            else
            {
                strTarget  = "000000000000000000000000000000000000000000000000";
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 8));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 16));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 24));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 32));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 40));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 48));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 56));
            }

            target = Utils.HexStringToByteArray(strTarget);
            //Utils.ByteSwapIntegers(target);

            mHashMan = new HashManager();
        }
示例#4
0
        public void Initialize(ulong serverDiff)
        {
            if (serverDiff == 0)
            {
                uint diff = Utils.HexStringToUInt(mDifficulty);
                int diffBytes = ((int)diff >> 24) & 0x000000FF;

                strTarget = "";
                for (int i = 0; i < diffBytes - 3; i++)
                    strTarget += "00";
                strTarget += string.Format("{0:X2}", (byte)diff);
                strTarget += string.Format("{0:X2}", (byte)((int)diff >> 8));
                strTarget += string.Format("{0:X2}", (byte)((int)diff >> 16));
                for (int i = diffBytes; i < 32; i++)
                    strTarget += "00";
            }
            else
            {
                strTarget = "000000000000000000000000000000000000000000000000";
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 8));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 16));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 24));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 32));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 40));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 48));
                strTarget += string.Format("{0:X2}", (byte)((long)serverDiff >> 56));
            }

            target = Utils.HexStringToByteArray(strTarget);
            //Utils.ByteSwapIntegers(target);

            mHashMan = new HashManager();
        }
示例#5
0
        public void SendWork(HashManager.HashBlock hashBlock, WorkBlock block)
        {
            mHashBlock = hashBlock;

            MemoryStream stream = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(stream);
            bw.Write((byte)3);
            bw.Write(hashBlock.Start);
            bw.Write(hashBlock.Count);
            bw.Write((int)block.mAlgorithm);
            bw.Write(block.target);
            bw.Write(block.data);

            SendPacket(stream.ToArray());
            bw.Close();

            mCurrentBlock = block;
            mState = State.Busy;
            mWorkSent = DateTime.Now;
        }