MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / GuessVerificationProgress

Function GuessVerificationProgress

src/checkpoints.cpp:37–64  ·  view source on GitHub ↗

Guess how far we are in the verification process at the given block index

Source from the content-addressed store, hash-verified

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

Callers 5

getblockchaininfoFunction · 0.85
UpdateTipFunction · 0.85
LoadBlockIndexDBFunction · 0.85

Calls 1

GetBlockTimeMethod · 0.45

Tested by

no test coverage detected