aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-01-24 15:58:16 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-01-24 16:00:40 +0100
commit40e96a30160ddc2cb39bc9b86ec103ac892e09ab (patch)
tree2a8e0334553b49b83f5d908d4ede86c177e8bbcf /src
parentb6acd4563d3b96b244e61b87b9f08c0eb61ecaa6 (diff)
parent0cc0d8d60b8aec483a926a94aa7f85b9b0d0aca3 (diff)
Merge pull request #5599
0cc0d8d Get rid of the internal miner's hashmeter (jtimon)
Diffstat (limited to 'src')
-rw-r--r--src/miner.cpp42
-rw-r--r--src/miner.h3
-rw-r--r--src/rpcmining.cpp20
-rw-r--r--src/rpcserver.cpp1
-rw-r--r--src/rpcserver.h1
5 files changed, 2 insertions, 65 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index cc97d16f0f..5cc4a92791 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -362,8 +362,6 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
//
// Internal miner
//
-double dHashesPerSec = 0.0;
-int64_t nHPSTimerStart = 0;
//
// ScanHash scans nonces looking for a hash with at least some zero bits.
@@ -393,10 +391,8 @@ bool static ScanHash(const CBlockHeader *pblock, uint32_t& nNonce, uint256 *phas
return true;
// If nothing found after trying for a while, return -1
- if ((nNonce & 0xffff) == 0)
- return false;
if ((nNonce & 0xfff) == 0)
- boost::this_thread::interruption_point();
+ return false;
}
}
@@ -483,14 +479,9 @@ void static BitcoinMiner(CWallet *pwallet)
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
uint256 hash;
uint32_t nNonce = 0;
- uint32_t nOldNonce = 0;
while (true) {
- bool fFound = ScanHash(pblock, nNonce, &hash);
- uint32_t nHashesDone = nNonce - nOldNonce;
- nOldNonce = nNonce;
-
// Check if something found
- if (fFound)
+ if (ScanHash(pblock, nNonce, &hash))
{
if (UintToArith256(hash) <= hashTarget)
{
@@ -512,35 +503,6 @@ void static BitcoinMiner(CWallet *pwallet)
}
}
- // Meter hashes/sec
- static int64_t nHashCounter;
- if (nHPSTimerStart == 0)
- {
- nHPSTimerStart = GetTimeMillis();
- nHashCounter = 0;
- }
- else
- nHashCounter += nHashesDone;
- if (GetTimeMillis() - nHPSTimerStart > 4000)
- {
- static CCriticalSection cs;
- {
- LOCK(cs);
- if (GetTimeMillis() - nHPSTimerStart > 4000)
- {
- dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart);
- nHPSTimerStart = GetTimeMillis();
- nHashCounter = 0;
- static int64_t nLogTime;
- if (GetTime() - nLogTime > 30 * 60)
- {
- nLogTime = GetTime();
- LogPrintf("hashmeter %6.0f khash/s\n", dHashesPerSec/1000.0);
- }
- }
- }
- }
-
// Check for stop or if block needs to be rebuilt
boost::this_thread::interruption_point();
// Regtest mode doesn't require peers
diff --git a/src/miner.h b/src/miner.h
index 593ddcd371..5d5c9c86c7 100644
--- a/src/miner.h
+++ b/src/miner.h
@@ -31,7 +31,4 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey);
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce);
void UpdateTime(CBlockHeader* block, const CBlockIndex* pindexPrev);
-extern double dHashesPerSec;
-extern int64_t nHPSTimerStart;
-
#endif // BITCOIN_MINER_H
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 603e2935dd..5df5de66d9 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -201,24 +201,6 @@ Value setgenerate(const Array& params, bool fHelp)
return Value::null;
}
-Value gethashespersec(const Array& params, bool fHelp)
-{
- if (fHelp || params.size() != 0)
- throw runtime_error(
- "gethashespersec\n"
- "\nReturns a recent hashes per second performance measurement while generating.\n"
- "See the getgenerate and setgenerate calls to turn generation on and off.\n"
- "\nResult:\n"
- "n (numeric) The recent hashes per second when generation is on (will return 0 if generation is off)\n"
- "\nExamples:\n"
- + HelpExampleCli("gethashespersec", "")
- + HelpExampleRpc("gethashespersec", "")
- );
-
- if (GetTimeMillis() - nHPSTimerStart > 8000)
- return (int64_t)0;
- return (int64_t)dHashesPerSec;
-}
#endif
@@ -237,7 +219,6 @@ Value getmininginfo(const Array& params, bool fHelp)
" \"errors\": \"...\" (string) Current errors\n"
" \"generate\": true|false (boolean) If the generation is on or off (see getgenerate or setgenerate calls)\n"
" \"genproclimit\": n (numeric) The processor limit for generation. -1 if no generation. (see getgenerate or setgenerate calls)\n"
- " \"hashespersec\": n (numeric) The hashes per second of the generation, or 0 if no generation.\n"
" \"pooledtx\": n (numeric) The size of the mem pool\n"
" \"testnet\": true|false (boolean) If using testnet or not\n"
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
@@ -260,7 +241,6 @@ Value getmininginfo(const Array& params, bool fHelp)
obj.push_back(Pair("chain", Params().NetworkIDString()));
#ifdef ENABLE_WALLET
obj.push_back(Pair("generate", getgenerate(params, false)));
- obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
#endif
return obj;
}
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index cb87142902..e4f23d56d2 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -281,7 +281,6 @@ static const CRPCCommand vRPCCommands[] =
#ifdef ENABLE_WALLET
/* Coin generation */
{ "generating", "getgenerate", &getgenerate, true, false, false },
- { "generating", "gethashespersec", &gethashespersec, true, false, false },
{ "generating", "setgenerate", &setgenerate, true, true, false },
#endif
diff --git a/src/rpcserver.h b/src/rpcserver.h
index fb561ab939..1b94b758f2 100644
--- a/src/rpcserver.h
+++ b/src/rpcserver.h
@@ -154,7 +154,6 @@ extern json_spirit::Value importwallet(const json_spirit::Array& params, bool fH
extern json_spirit::Value getgenerate(const json_spirit::Array& params, bool fHelp); // in rpcmining.cpp
extern json_spirit::Value setgenerate(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getnetworkhashps(const json_spirit::Array& params, bool fHelp);
-extern json_spirit::Value gethashespersec(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getmininginfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value prioritisetransaction(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getblocktemplate(const json_spirit::Array& params, bool fHelp);