Exemplo n.º 1
0
        /// <summary>
        ///  Initializes a new instance of the <see cref="Work"/> class.
        /// </summary>
        public Work(byte[] data)
        {
            //Remember to use little-endian.
            var decodedData = SwapInt32(data, 1, 8);

            decodedData = SwapInt32(decodedData, 9, 8);

            //decode the block hash
            Version          = BitConverter.ToInt32(decodedData, 0);
            PreviousHash     = BitConverter.ToString(decodedData, 4, 32).Replace("-", string.Empty);
            MerkleRoot       = BitConverter.ToString(decodedData, 36, 32).Replace("-", string.Empty);
            TimestampSeconds = BitConverter.ToInt32(decodedData, 68);
            Timestamp        = UnixTime.ConvertFromUnixTimestamp(TimestampSeconds);
            Target           = BitConverter.ToInt32(decodedData, 72);
            Nonce            = BitConverter.ToInt32(decodedData, 76);

            //for delay hash computing the first 80 bytes
            UnderlyingData = new byte[80];
            Array.Copy(data, 0, UnderlyingData, 0, 80);
        }