Skip to content

Commit 3641141

Browse files
committed
Move tx estimation data out of CCheckPointData
1 parent a4bac66 commit 3641141

File tree

7 files changed

+28
-13
lines changed

7 files changed

+28
-13
lines changed

src/chainparams.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ class CMainParams : public CChainParams {
151151
(225430, uint256S("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932"))
152152
(250000, uint256S("0x000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214"))
153153
(279000, uint256S("0x0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40"))
154-
(295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983")),
154+
(295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983"))
155+
};
156+
157+
chainTxData = ChainTxData{
155158
1397080064, // * UNIX timestamp of last checkpoint block
156159
36544669, // * total number of transactions between genesis and last checkpoint
157160
// (the tx=... number in the SetBestChain debug.log lines)
@@ -234,6 +237,9 @@ class CTestNetParams : public CChainParams {
234237
checkpointData = (CCheckpointData) {
235238
boost::assign::map_list_of
236239
( 546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")),
240+
};
241+
242+
chainTxData = ChainTxData{
237243
1337966069,
238244
1488,
239245
300
@@ -297,11 +303,15 @@ class CRegTestParams : public CChainParams {
297303

298304
checkpointData = (CCheckpointData){
299305
boost::assign::map_list_of
300-
( 0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")),
306+
( 0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"))
307+
};
308+
309+
chainTxData = ChainTxData{
301310
0,
302311
0,
303312
0
304313
};
314+
305315
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
306316
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
307317
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);

src/chainparams.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ typedef std::map<int, uint256> MapCheckpoints;
2828

2929
struct CCheckpointData {
3030
MapCheckpoints mapCheckpoints;
31+
};
32+
33+
struct ChainTxData {
3134
int64_t nTimeLastCheckpoint;
3235
int64_t nTransactionsLastCheckpoint;
3336
double fTransactionsPerDay;
@@ -73,6 +76,7 @@ class CChainParams
7376
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
7477
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
7578
const CCheckpointData& Checkpoints() const { return checkpointData; }
79+
const ChainTxData& TxData() const { return chainTxData; }
7680
protected:
7781
CChainParams() {}
7882

@@ -90,6 +94,7 @@ class CChainParams
9094
bool fRequireStandard;
9195
bool fMineBlocksOnDemand;
9296
CCheckpointData checkpointData;
97+
ChainTxData chainTxData;
9398
};
9499

95100
/**

src/qt/clientmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const
130130
LOCK(cs_main);
131131
tip = chainActive.Tip();
132132
}
133-
return GuessVerificationProgress(Params().Checkpoints(), tip);
133+
return GuessVerificationProgress(Params().TxData(), tip);
134134
}
135135

136136
void ClientModel::updateTimer()

src/rpc/blockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
10731073
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
10741074
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
10751075
obj.push_back(Pair("mediantime", (int64_t)chainActive.Tip()->GetMedianTimePast()));
1076-
obj.push_back(Pair("verificationprogress", GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip())));
1076+
obj.push_back(Pair("verificationprogress", GuessVerificationProgress(Params().TxData(), chainActive.Tip())));
10771077
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
10781078
obj.push_back(Pair("pruned", fPruneMode));
10791079

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,7 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
20802080
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), chainActive.Tip()->nVersion,
20812081
log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
20822082
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
2083-
GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
2083+
GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
20842084
if (!warningMessages.empty())
20852085
LogPrintf(" warning='%s'", boost::algorithm::join(warningMessages, ", "));
20862086
LogPrintf("\n");
@@ -3445,7 +3445,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
34453445
LogPrintf("%s: hashBestChain=%s height=%d date=%s progress=%f\n", __func__,
34463446
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(),
34473447
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
3448-
GuessVerificationProgress(chainparams.Checkpoints(), chainActive.Tip()));
3448+
GuessVerificationProgress(chainparams.TxData(), chainActive.Tip()));
34493449

34503450
return true;
34513451
}
@@ -4152,7 +4152,7 @@ void DumpMempool(void)
41524152
static const double SIGCHECK_VERIFICATION_FACTOR = 5.0;
41534153

41544154
//! Guess how far we are in the verification process at the given block index
4155-
double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex *pindex, bool fSigchecks) {
4155+
double GuessVerificationProgress(const ChainTxData& data, CBlockIndex *pindex, bool fSigchecks) {
41564156
if (pindex==NULL)
41574157
return 0.0;
41584158

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CScriptCheck;
4242
class CTxMemPool;
4343
class CValidationInterface;
4444
class CValidationState;
45-
class CCheckpointData;
45+
struct ChainTxData;
4646

4747
struct PrecomputedTransactionData;
4848
struct LockPoints;
@@ -281,7 +281,7 @@ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams,
281281
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
282282

283283
/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
284-
double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex* pindex, bool fSigchecks = true);
284+
double GuessVerificationProgress(const ChainTxData& data, CBlockIndex* pindex, bool fSigchecks = true);
285285

286286
/**
287287
* Prune block and undo files (blk???.dat and undo???.dat) so that the disk space used is less than a user-defined target.

src/wallet/wallet.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,12 +1479,12 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
14791479
pindex = chainActive.Next(pindex);
14801480

14811481
ShowProgress(_("Rescanning..."), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
1482-
double dProgressStart = GuessVerificationProgress(chainParams.Checkpoints(), pindex, false);
1483-
double dProgressTip = GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip(), false);
1482+
double dProgressStart = GuessVerificationProgress(chainParams.TxData(), pindex, false);
1483+
double dProgressTip = GuessVerificationProgress(chainParams.TxData(), chainActive.Tip(), false);
14841484
while (pindex)
14851485
{
14861486
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0)
1487-
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
1487+
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((GuessVerificationProgress(chainParams.TxData(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
14881488

14891489
CBlock block;
14901490
ReadBlockFromDisk(block, pindex, Params().GetConsensus());
@@ -1497,7 +1497,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
14971497
pindex = chainActive.Next(pindex);
14981498
if (GetTime() >= nNow + 60) {
14991499
nNow = GetTime();
1500-
LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, GuessVerificationProgress(chainParams.Checkpoints(), pindex));
1500+
LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, GuessVerificationProgress(chainParams.TxData(), pindex));
15011501
}
15021502
}
15031503
ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI

0 commit comments

Comments
 (0)