Protocol switch of entropy bit calculation for novacoin support of p2pool
[novacoin.git] / src / main.h
index 7e05562..e3f454f 100644 (file)
@@ -966,8 +966,18 @@ public:
     void UpdateTime(const CBlockIndex* pindexPrev);
 
     // ppcoin: entropy bit for stake modifier if chosen by modifier
-    unsigned int GetStakeEntropyBit() const
+    unsigned int GetStakeEntropyBit(unsigned int nHeight) const
     {
+        // Protocol switch to support p2pool at novacoin block #9689
+        if (nHeight >= 9689)
+        {
+            // Take last bit of block hash as entropy bit
+            unsigned int nEntropyBit = ((GetHash().Get64()) & 1llu);
+            if (fDebug && GetBoolArg("-printstakemodifier"))
+                printf("GetStakeEntropyBit: nHeight=%u hashBlock=%s nEntropyBit=%u\n", nHeight, GetHash().ToString().c_str(), nEntropyBit);
+            return nEntropyBit;
+        }
+        // Before novacoin block #9689 - old protocol
         uint160 hashSig = Hash160(vchBlockSig);
         if (fDebug && GetBoolArg("-printstakemodifier"))
             printf("GetStakeEntropyBit: hashSig=%s", hashSig.ToString().c_str());