Merge pull request #769 from letolabs/ac_progress
Fix progress estimate for asset chains in UpdateTip
This commit is contained in:
27
src/main.cpp
27
src/main.cpp
@@ -3195,10 +3195,19 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
|||||||
nTimeBestReceived = GetTime();
|
nTimeBestReceived = GetTime();
|
||||||
mempool.AddTransactionsUpdated(1);
|
mempool.AddTransactionsUpdated(1);
|
||||||
KOMODO_NEWBLOCKS++;
|
KOMODO_NEWBLOCKS++;
|
||||||
|
double progress;
|
||||||
|
if ( ASSETCHAINS_SYMBOL[0] == 0 ) {
|
||||||
|
progress = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip());
|
||||||
|
} else {
|
||||||
|
int32_t longestchain = komodo_longestchain();
|
||||||
|
progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
|
LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
|
||||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
|
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(),
|
||||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
|
log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
|
||||||
Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()), progress,
|
||||||
|
pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
|
||||||
|
|
||||||
cvBlockChange.notify_all();
|
cvBlockChange.notify_all();
|
||||||
|
|
||||||
@@ -4850,11 +4859,21 @@ bool static LoadBlockIndexDB()
|
|||||||
it->second->hashAnchorEnd = pcoinsTip->GetBestAnchor();
|
it->second->hashAnchorEnd = pcoinsTip->GetBestAnchor();
|
||||||
|
|
||||||
PruneBlockIndexCandidates();
|
PruneBlockIndexCandidates();
|
||||||
|
|
||||||
|
double progress;
|
||||||
|
if ( ASSETCHAINS_SYMBOL[0] == 0 ) {
|
||||||
|
progress = Checkpoints::GuessVerificationProgress(chainparams.Checkpoints(), chainActive.Tip());
|
||||||
|
} else {
|
||||||
|
int32_t longestchain = komodo_longestchain();
|
||||||
|
// TODO: komodo_longestchain does not have the data it needs at the time LoadBlockIndexDB
|
||||||
|
// runs, which makes it return 0, so we guess 50% for now
|
||||||
|
progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
LogPrintf("%s: hashBestChain=%s height=%d date=%s progress=%f\n", __func__,
|
LogPrintf("%s: hashBestChain=%s height=%d date=%s progress=%f\n", __func__,
|
||||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(),
|
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(),
|
||||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
|
||||||
Checkpoints::GuessVerificationProgress(chainparams.Checkpoints(), chainActive.Tip()));
|
progress);
|
||||||
|
|
||||||
EnforceNodeDeprecation(chainActive.Height(), true);
|
EnforceNodeDeprecation(chainActive.Height(), true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user