/// </summary>
public class CBlock
{
+ /// <summary>
+ /// Maximum block size is 1Mb.
+ /// </summary>
+ public const uint nMaxBlockSize = 1000000;
+
/// <summary>
/// Block header.
/// </summary>
var reader = new BinaryReader(stream);
// Fill the block header fields
- header = new CBlockHeader();
- header.nVersion = reader.ReadUInt32();
- header.prevHash = new ScryptHash256(reader.ReadBytes(32));
- header.merkleRoot = new Hash256(reader.ReadBytes(32));
- header.nTime = reader.ReadUInt32();
- header.nBits = reader.ReadUInt32();
- header.nNonce = reader.ReadUInt32();
+ header = new CBlockHeader(ref reader);
// Parse transactions list
vtx = CTransaction.ReadTransactionsList(ref reader);
uint nSigOps = 0; // total sigops
// Basic sanity checkings
- if (vtx.Length == 0 || Size > 1000000)
+ if (vtx.Length == 0 || Size > nMaxBlockSize)
{
return false;
}