From 167517ffee2ac1111d2a492fd0c68a011e9f0c97 Mon Sep 17 00:00:00 2001 From: Sunny King Date: Fri, 29 Jun 2012 02:31:53 +0100 Subject: [PATCH] PPCoin: RPC commands show difficulty of proof-of-work blocks only --- src/bitcoinrpc.cpp | 5 +++-- src/main.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 583884d..bd988e9 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -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) { diff --git a/src/main.h b/src/main.h index 2748269..42d3759 100644 --- a/src/main.h +++ b/src/main.h @@ -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); -- 1.7.1