diff options
author | Jeff Garzik <jgarzik@bitpay.com> | 2013-05-30 07:44:42 -0700 |
---|---|---|
committer | Jeff Garzik <jgarzik@bitpay.com> | 2013-05-30 07:44:42 -0700 |
commit | 1803fa1db995e61258f1542e1766aec5b104d87d (patch) | |
tree | 94a295f22e1ba1ccfd6b984d89c3722d1719e482 /src | |
parent | 9d01dd7658b38ba947347156e13b677ee57d80b4 (diff) | |
parent | f0d8a52cc039cda77730047db2443fbec016f852 (diff) |
Merge pull request #2693 from jgarzik/checkpoint-bool
Replace repeated GetBoolArg() calls with Checkpoint::fEnabled variable set once at init time
Diffstat (limited to 'src')
-rw-r--r-- | src/checkpoints.cpp | 8 | ||||
-rw-r--r-- | src/checkpoints.h | 2 | ||||
-rw-r--r-- | src/init.cpp | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 9e8e0f7024..7643ec5df8 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -28,6 +28,8 @@ namespace Checkpoints double fTransactionsPerDay; }; + bool fEnabled = true; + // What makes a good checkpoint block? // + Is surrounded by blocks with reasonable timestamps // (no blocks before with a timestamp after, none after with @@ -74,7 +76,7 @@ namespace Checkpoints bool CheckBlock(int nHeight, const uint256& hash) { - if (!GetBoolArg("-checkpoints", true)) + if (!fEnabled) return true; const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints; @@ -117,7 +119,7 @@ namespace Checkpoints int GetTotalBlocksEstimate() { - if (!GetBoolArg("-checkpoints", true)) + if (!fEnabled) return 0; const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints; @@ -127,7 +129,7 @@ namespace Checkpoints CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex) { - if (!GetBoolArg("-checkpoints", true)) + if (!fEnabled) return NULL; const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints; diff --git a/src/checkpoints.h b/src/checkpoints.h index 3d56885556..a49a908a38 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -24,6 +24,8 @@ namespace Checkpoints CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex); double GuessVerificationProgress(CBlockIndex *pindex); + + extern bool fEnabled; } #endif diff --git a/src/init.cpp b/src/init.cpp index 767d7525a6..2175f73d70 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -10,6 +10,7 @@ #include "init.h" #include "util.h" #include "ui_interface.h" +#include "checkpoints.h" #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> @@ -494,6 +495,7 @@ bool AppInit2(boost::thread_group& threadGroup) // ********************************************************* Step 2: parameter interactions fTestNet = GetBoolArg("-testnet"); + Checkpoints::fEnabled = GetBoolArg("-checkpoints", true); if (mapArgs.count("-bind")) { // when specifying an explicit binding address, you want to listen on it |