uint160 and uint256 division operations.
[NovacoinLibrary.git] / Novacoin / CBlockStore.cs
index a9c504c..a579898 100644 (file)
@@ -61,6 +61,11 @@ namespace Novacoin
         public uint nNonce { get; set; }
 
         /// <summary>
+        /// Next block hash.
+        /// </summary>
+        public byte[] nextHash { get; set; }
+
+        /// <summary>
         /// Block type flags
         /// </summary>
         public BlockType BlockTypeFlag { get; set; }
@@ -76,6 +81,11 @@ namespace Novacoin
         public byte nEntropyBit { get; set; }
 
         /// <summary>
+        /// Proof-of-Stake hash
+        /// </summary>
+        public byte[] hashProofOfStake { get; set; }
+
+        /// <summary>
         /// Block height
         /// </summary>
         public uint nHeight { get; set; }
@@ -211,18 +221,37 @@ namespace Novacoin
         /// <summary>
         /// Previous block cursor
         /// </summary>
-        public public CBlockStoreItem prev {
+        public CBlockStoreItem prev {
             get { return CBlockStore.Instance.GetCursor(prevHash); }
         }
 
         /// <summary>
-        /// STake modifier generation flag
+        /// Next block cursor
         /// </summary>
-        public bool GeneratedStakeModifier
+        public CBlockStoreItem next
+        {
+            get { return CBlockStore.Instance.GetCursor(nextHash); }
+        }
+
+        bool IsInMainChain
+        {
+            get { return (next != null); }
+        }
+
+
+    /// <summary>
+    /// STake modifier generation flag
+    /// </summary>
+    public bool GeneratedStakeModifier
         {
             get { return (BlockTypeFlag & BlockType.BLOCK_STAKE_MODIFIER) != 0; }
         }
 
+        public uint StakeEntropyBit
+        {
+            get { return ((uint)(BlockTypeFlag & BlockType.BLOCK_STAKE_ENTROPY) >> 1); }
+        }
+
         /// <summary>
         /// Sets stake modifier and flag.
         /// </summary>
@@ -513,7 +542,10 @@ namespace Novacoin
             // TODO: compute stake modifier
 
             // Add to index
-            itemTemplate.BlockTypeFlag = block.IsProofOfStake ? BlockType.PROOF_OF_STAKE : BlockType.PROOF_OF_WORK;
+            if (block.IsProofOfStake)
+            {
+                itemTemplate.SetProofOfStake();
+            }
 
             if (!itemTemplate.WriteToFile(ref writer, ref block))
             {