diff options
Diffstat (limited to 'src/checkpoints.cpp')
| -rw-r--r-- | src/checkpoints.cpp | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 71579bb30..a9822eed8 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -4,6 +4,7 @@ #include "checkpoints.h" +#include "chain.h" #include "chainparams.h" #include "main.h" #include "uint256.h" @@ -15,30 +16,17 @@ namespace Checkpoints { /** - * How many times we expect transactions after the last checkpoint to - * be slower. This number is a compromise, as it can't be accurate for - * every system. When reindexing from a fast disk with a slow CPU, it + * How many times slower we expect checking transactions after the last + * checkpoint to be (from checking signatures, which is skipped up to the + * last checkpoint). This number is a compromise, as it can't be accurate + * for every system. When reindexing from a fast disk with a slow CPU, it * can be up to 20, while when downloading from a slow network with a * fast multicore CPU, it won't be much higher than 1. */ static const double SIGCHECK_VERIFICATION_FACTOR = 5.0; - bool fEnabled = true; - - bool CheckBlock(int nHeight, const uint256& hash) - { - if (!fEnabled) - return true; - - const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints; - - MapCheckpoints::const_iterator i = checkpoints.find(nHeight); - if (i == checkpoints.end()) return true; - return hash == i->second; - } - //! Guess how far we are in the verification process at the given block index - double GuessVerificationProgress(CBlockIndex *pindex, bool fSigchecks) { + double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex *pindex, bool fSigchecks) { if (pindex==NULL) return 0.0; @@ -50,8 +38,6 @@ namespace Checkpoints { // Work is defined as: 1.0 per transaction before the last checkpoint, and // fSigcheckVerificationFactor per transaction after. - const CCheckpointData &data = Params().Checkpoints(); - if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) { double nCheapBefore = pindex->nChainTx; double nCheapAfter = data.nTransactionsLastCheckpoint - pindex->nChainTx; @@ -69,22 +55,19 @@ namespace Checkpoints { return fWorkBefore / (fWorkBefore + fWorkAfter); } - int GetTotalBlocksEstimate() + int GetTotalBlocksEstimate(const CCheckpointData& data) { - if (!fEnabled) - return 0; + const MapCheckpoints& checkpoints = data.mapCheckpoints; - const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints; + if (checkpoints.empty()) + return 0; return checkpoints.rbegin()->first; } - CBlockIndex* GetLastCheckpoint() + CBlockIndex* GetLastCheckpoint(const CCheckpointData& data) { - if (!fEnabled) - return NULL; - - const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints; + const MapCheckpoints& checkpoints = data.mapCheckpoints; BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints) { |