From bfb4d29fa9612b838ddf64ff2f2d40564e8860b6 Mon Sep 17 00:00:00 2001 From: pooler Date: Thu, 29 Aug 2013 18:21:44 +0200 Subject: [PATCH] Use nChainWork in GetNetworkHashPS() --- src/rpcmining.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 67ebcb7c8..d5d16d7b7 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -31,14 +31,14 @@ Value GetNetworkHashPS(int lookup, int height) { if (lookup > pb->nHeight) lookup = pb->nHeight; - double sum = 0.0; + CBlockIndex *pb0 = pb; for (int i = 0; i < lookup; i++) - { - sum += (pb->GetBlockTime() - pb->pprev->GetBlockTime()) / GetDifficulty(pb); - pb = pb->pprev; - } + pb0 = pb0->pprev; + + uint256 workDiff = pb->nChainWork - pb0->nChainWork; + int64 timeDiff = pb->GetBlockTime() - pb0->GetBlockTime(); - return (boost::int64_t)(pow(2.0, 32) / (sum / lookup)); + return (boost::int64_t)(workDiff.getdouble() / timeDiff); } Value getnetworkhashps(const Array& params, bool fHelp)