Guess how far we are in the verification process at the given block index
| 41 | |
| 42 | //! Guess how far we are in the verification process at the given block index |
| 43 | double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex *pindex, bool fSigchecks) |
| 44 | { |
| 45 | if (pindex == NULL) |
| 46 | return 0.0; |
| 47 | |
| 48 | int64_t nNow = time(NULL); |
| 49 | |
| 50 | double fSigcheckVerificationFactor = fSigchecks ? SIGCHECK_VERIFICATION_FACTOR : 1.0; |
| 51 | double fWorkBefore = 0.0; // Amount of work done before pindex |
| 52 | double fWorkAfter = 0.0; // Amount of work left after pindex (estimated) |
| 53 | // Work is defined as: 1.0 per transaction before the last checkpoint, and |
| 54 | // fSigcheckVerificationFactor per transaction after. |
| 55 | |
| 56 | // const CCheckpointData& data = Params().Checkpoints(); |
| 57 | |
| 58 | if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) { |
| 59 | double nCheapBefore = pindex->nChainTx; |
| 60 | double nCheapAfter = data.nTransactionsLastCheckpoint - pindex->nChainTx; |
| 61 | double nExpensiveAfter = (nNow - data.nTimeLastCheckpoint) / 86400.0 * data.fTransactionsPerDay; |
| 62 | fWorkBefore = nCheapBefore; |
| 63 | fWorkAfter = nCheapAfter + nExpensiveAfter * fSigcheckVerificationFactor; |
| 64 | } else { |
| 65 | double nCheapBefore = data.nTransactionsLastCheckpoint; |
| 66 | double nExpensiveBefore = pindex->nChainTx - data.nTransactionsLastCheckpoint; |
| 67 | double nExpensiveAfter = (nNow - pindex->GetBlockTime()) / 86400.0 * data.fTransactionsPerDay; |
| 68 | fWorkBefore = nCheapBefore + nExpensiveBefore * fSigcheckVerificationFactor; |
| 69 | fWorkAfter = nExpensiveAfter * fSigcheckVerificationFactor; |
| 70 | } |
| 71 | |
| 72 | return fWorkBefore / (fWorkBefore + fWorkAfter); |
| 73 | } |
| 74 | |
| 75 | int GetTotalBlocksEstimate(const CCheckpointData& data) |
| 76 | { |
no test coverage detected