PPCoin: RPC commands show difficulty of proof-of-work blocks only
authorSunny King <sunnyking9999@gmail.com>
Fri, 29 Jun 2012 01:31:53 +0000 (02:31 +0100)
committerSunny King <sunnyking9999@gmail.com>
Fri, 29 Jun 2012 01:31:53 +0000 (02:31 +0100)
src/bitcoinrpc.cpp
src/main.h

index 583884d..bd988e9 100644 (file)
@@ -216,10 +216,11 @@ double GetDifficulty()
 
     if (pindexBest == NULL)
         return 1.0;
-    int nShift = (pindexBest->nBits >> 24) & 0xff;
+    const CBlockIndex* pindexLastProofOfWork = GetLastBlockIndex(pindexBest, false);
+    int nShift = (pindexLastProofOfWork->nBits >> 24) & 0xff;
 
     double dDiff =
-        (double)0x0000ffff / (double)(pindexBest->nBits & 0x00ffffff);
+        (double)0x0000ffff / (double)(pindexLastProofOfWork->nBits & 0x00ffffff);
 
     while (nShift < 29)
     {
index 2748269..42d3759 100644 (file)
@@ -110,6 +110,7 @@ bool IsInitialBlockDownload();
 std::string GetWarnings(std::string strFor);
 bool Reorganize(CTxDB& txdb, CBlockIndex* pindexNew);
 uint256 WantedByOrphan(const CBlock* pblockOrphan);
+const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake);