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 ()
49 public CBlockHeader(CBlockHeader h)
51 nVersion = h.nVersion;
52 prevHash = new Hash256(h.prevHash);
53 merkleRoot = new Hash256(h.merkleRoot);
60 /// Convert current block header instance into sequence of bytes
62 /// <returns>Byte sequence</returns>
63 public IList<byte> Bytes
67 List<byte> r = new List<byte>();
69 r.AddRange(BitConverter.GetBytes(nVersion));
70 r.AddRange(prevHash.hashBytes);
71 r.AddRange(merkleRoot.hashBytes);
72 r.AddRange(BitConverter.GetBytes(nTime));
73 r.AddRange(BitConverter.GetBytes(nBits));
74 r.AddRange(BitConverter.GetBytes(nNonce));
80 public override string ToString()
82 StringBuilder sb = new StringBuilder();
83 sb.AppendFormat("CBlockHeader(nVersion={0}, prevHash={1}, merkleRoot={2}, nTime={3}, nBits={4}, nNonce={5})", nVersion, prevHash.ToString(), merkleRoot.ToString(), nTime, nBits, nNonce);