Yet another cosmetic change.
[NovacoinLibrary.git] / Novacoin / CBlock.cs
index 101d20e..8ac3cad 100644 (file)
@@ -47,6 +47,11 @@ namespace Novacoin
     /// </summary>
     public class CBlock
        {
+        /// <summary>
+        /// Maximum block size is 1Mb.
+        /// </summary>
+        public const uint nMaxBlockSize = 1000000;
+
                /// <summary>
                /// Block header.
                /// </summary>
@@ -92,13 +97,7 @@ namespace Novacoin
                 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);
@@ -128,7 +127,7 @@ namespace Novacoin
             uint nSigOps = 0; // total sigops
 
             // Basic sanity checkings
-            if (vtx.Length == 0 || Size > 1000000)
+            if (vtx.Length == 0 || Size > nMaxBlockSize)
             {
                 return false;
             }