3 using System.Collections.Generic;
10 public class CBlockHeader
13 /// Version of block schema.
15 public uint nVersion = 6;
18 /// Previous block hash.
20 public Hash256 prevHash = new Hash256();
25 public Hash256 merkleRoot = new Hash256();
30 public uint nTime = 0;
33 /// Compressed difficulty representation.
35 public uint nBits = 0;
40 public uint nNonce = 0;
43 /// Initialize an empty instance
45 public CBlockHeader ()
50 /// Convert current block header instance into sequence of bytes
52 /// <returns>Byte sequence</returns>
53 public IList<byte> ToBytes()
55 List<byte> r = new List<byte>();
57 r.AddRange(BitConverter.GetBytes(nVersion));
58 r.AddRange(prevHash.hashBytes);
59 r.AddRange(merkleRoot.hashBytes);
60 r.AddRange(BitConverter.GetBytes(nTime));
61 r.AddRange(BitConverter.GetBytes(nBits));
62 r.AddRange(BitConverter.GetBytes(nNonce));
67 public override string ToString()
69 StringBuilder sb = new StringBuilder();
70 sb.AppendFormat("CBlockHeader(nVersion={0}, prevHash={1}, merkleRoot={2}, nTime={3}, nBits={4}, nNonce={5})", nVersion, prevHash.ToString(), merkleRoot.ToString(), nTime, nBits, nNonce);