PPCoin: target adjustment for both proof-of-work and proof-of-stake
[novacoin.git] / src / main.h
index ea73a0f..4e82e1b 100644 (file)
@@ -1116,6 +1116,7 @@ public:
     uint64 nChainTrust;// ppcoin: trust score of chain, in the unit of coin-days
     int nHeight;
     int nCheckpoint;    // ppcoin: chain auto checkpoint height
+    bool fProofOfStake; // ppcoin: is the block of proof-of-stake type
 
     // block header
     int nVersion;
@@ -1135,6 +1136,7 @@ public:
         nHeight = 0;
         nChainTrust = 0;
         nCheckpoint = 0;
+        fProofOfStake = true;
 
         nVersion       = 0;
         hashMerkleRoot = 0;
@@ -1153,6 +1155,7 @@ public:
         nHeight = 0;
         nChainTrust = 0;
         nCheckpoint = 0;
+        fProofOfStake = block.IsProofOfStake();
 
         nVersion       = block.nVersion;
         hashMerkleRoot = block.hashMerkleRoot;
@@ -1242,12 +1245,20 @@ public:
         return pindex->GetMedianTimePast();
     }
 
+    bool IsProofOfWork() const
+    {
+        return !fProofOfStake;
+    }
 
+    bool IsProofOfStake() const
+    {
+        return fProofOfStake;
+    }
 
     std::string ToString() const
     {
-        return strprintf("CBlockIndex(nprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nChainTrust=%"PRI64d" nHeight=%d, nCheckpoint=%d, merkle=%s, hashBlock=%s)",
-            pprev, pnext, nFile, nBlockPos, nChainTrust, nHeight, nCheckpoint,
+        return strprintf("CBlockIndex(nprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nChainTrust=%"PRI64d" nHeight=%d, nCheckpoint=%d, fProofOfStake=%d merkle=%s, hashBlock=%s)",
+            pprev, pnext, nFile, nBlockPos, nChainTrust, nHeight, nCheckpoint, fProofOfStake,
             hashMerkleRoot.ToString().substr(0,10).c_str(),
             GetBlockHash().ToString().substr(0,20).c_str());
     }
@@ -1292,6 +1303,7 @@ public:
         READWRITE(nChainTrust);
         READWRITE(nHeight);
         READWRITE(nCheckpoint);
+        READWRITE(fProofOfStake);
 
         // block header
         READWRITE(this->nVersion);