aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/chainparams.cpp28
-rw-r--r--src/chainparams.h11
-rw-r--r--src/checkpoints.cpp40
-rw-r--r--src/checkpoints.h2
-rw-r--r--src/qt/clientmodel.cpp2
-rw-r--r--src/rpc/blockchain.cpp2
-rw-r--r--src/validation.cpp22
-rw-r--r--src/validation.h4
-rw-r--r--src/wallet/wallet.cpp8
9 files changed, 58 insertions, 61 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 1e294da9f4..66b5d48fd9 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -151,11 +151,15 @@ public:
(225430, uint256S("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932"))
(250000, uint256S("0x000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214"))
(279000, uint256S("0x0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40"))
- (295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983")),
- 1397080064, // * UNIX timestamp of last checkpoint block
- 36544669, // * total number of transactions between genesis and last checkpoint
+ (295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983"))
+ };
+
+ chainTxData = ChainTxData{
+ // Data as of block 00000000000000000166d612d5595e2b1cd88d71d695fc580af64d8da8658c23 (height 446482).
+ 1483472411, // * UNIX timestamp of last known number of transactions
+ 184495391, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the SetBestChain debug.log lines)
- 60000.0 // * estimated number of transactions per day after checkpoint
+ 3.2 // * estimated number of transactions per second after that timestamp
};
}
};
@@ -234,9 +238,13 @@ public:
checkpointData = (CCheckpointData) {
boost::assign::map_list_of
( 546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")),
- 1337966069,
- 1488,
- 300
+ };
+
+ chainTxData = ChainTxData{
+ // Data as of block 00000000c2872f8f8a8935c8e3c5862be9038c97d4de2cf37ed496991166928a (height 1063660)
+ 1483546230,
+ 12834668,
+ 0.15
};
}
@@ -297,11 +305,15 @@ public:
checkpointData = (CCheckpointData){
boost::assign::map_list_of
- ( 0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")),
+ ( 0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"))
+ };
+
+ chainTxData = ChainTxData{
0,
0,
0
};
+
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
diff --git a/src/chainparams.h b/src/chainparams.h
index 381bac12f9..db524e8f8e 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -28,9 +28,12 @@ typedef std::map<int, uint256> MapCheckpoints;
struct CCheckpointData {
MapCheckpoints mapCheckpoints;
- int64_t nTimeLastCheckpoint;
- int64_t nTransactionsLastCheckpoint;
- double fTransactionsPerDay;
+};
+
+struct ChainTxData {
+ int64_t nTime;
+ int64_t nTxCount;
+ double dTxRate;
};
/**
@@ -73,6 +76,7 @@ public:
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
const CCheckpointData& Checkpoints() const { return checkpointData; }
+ const ChainTxData& TxData() const { return chainTxData; }
protected:
CChainParams() {}
@@ -90,6 +94,7 @@ protected:
bool fRequireStandard;
bool fMineBlocksOnDemand;
CCheckpointData checkpointData;
+ ChainTxData chainTxData;
};
/**
diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp
index 9a20747049..13b5876530 100644
--- a/src/checkpoints.cpp
+++ b/src/checkpoints.cpp
@@ -15,46 +15,6 @@
namespace Checkpoints {
- /**
- * 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;
-
- //! Guess how far we are in the verification process at the given block index
- double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex *pindex, bool fSigchecks) {
- if (pindex==NULL)
- return 0.0;
-
- int64_t nNow = time(NULL);
-
- double fSigcheckVerificationFactor = fSigchecks ? SIGCHECK_VERIFICATION_FACTOR : 1.0;
- double fWorkBefore = 0.0; // Amount of work done before pindex
- double fWorkAfter = 0.0; // Amount of work left after pindex (estimated)
- // Work is defined as: 1.0 per transaction before the last checkpoint, and
- // fSigcheckVerificationFactor per transaction after.
-
- if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) {
- double nCheapBefore = pindex->nChainTx;
- double nCheapAfter = data.nTransactionsLastCheckpoint - pindex->nChainTx;
- double nExpensiveAfter = (nNow - data.nTimeLastCheckpoint)/86400.0*data.fTransactionsPerDay;
- fWorkBefore = nCheapBefore;
- fWorkAfter = nCheapAfter + nExpensiveAfter*fSigcheckVerificationFactor;
- } else {
- double nCheapBefore = data.nTransactionsLastCheckpoint;
- double nExpensiveBefore = pindex->nChainTx - data.nTransactionsLastCheckpoint;
- double nExpensiveAfter = (nNow - pindex->GetBlockTime())/86400.0*data.fTransactionsPerDay;
- fWorkBefore = nCheapBefore + nExpensiveBefore*fSigcheckVerificationFactor;
- fWorkAfter = nExpensiveAfter*fSigcheckVerificationFactor;
- }
-
- return fWorkBefore / (fWorkBefore + fWorkAfter);
- }
-
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data)
{
const MapCheckpoints& checkpoints = data.mapCheckpoints;
diff --git a/src/checkpoints.h b/src/checkpoints.h
index f826de2319..7449d1063b 100644
--- a/src/checkpoints.h
+++ b/src/checkpoints.h
@@ -22,8 +22,6 @@ namespace Checkpoints
//! Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data);
-double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex* pindex, bool fSigchecks = true);
-
} //namespace Checkpoints
#endif // BITCOIN_CHECKPOINTS_H
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 20a04dc8a8..bb10e49422 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -130,7 +130,7 @@ double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const
LOCK(cs_main);
tip = chainActive.Tip();
}
- return Checkpoints::GuessVerificationProgress(Params().Checkpoints(), tip);
+ return GuessVerificationProgress(Params().TxData(), tip);
}
void ClientModel::updateTimer()
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index f7cbd04664..bbcbde71cd 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1120,7 +1120,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("mediantime", (int64_t)chainActive.Tip()->GetMedianTimePast()));
- obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip())));
+ obj.push_back(Pair("verificationprogress", GuessVerificationProgress(Params().TxData(), chainActive.Tip())));
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
obj.push_back(Pair("pruned", fPruneMode));
diff --git a/src/validation.cpp b/src/validation.cpp
index 109a71fe74..3faa1bf005 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2106,7 +2106,7 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), chainActive.Tip()->nVersion,
log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
- Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
+ GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
if (!warningMessages.empty())
LogPrintf(" warning='%s'", boost::algorithm::join(warningMessages, ", "));
LogPrintf("\n");
@@ -3500,7 +3500,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
LogPrintf("%s: hashBestChain=%s height=%d date=%s progress=%f\n", __func__,
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(),
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
- Checkpoints::GuessVerificationProgress(chainparams.Checkpoints(), chainActive.Tip()));
+ GuessVerificationProgress(chainparams.TxData(), chainActive.Tip()));
return true;
}
@@ -4198,6 +4198,24 @@ void DumpMempool(void)
}
}
+//! Guess how far we are in the verification process at the given block index
+double GuessVerificationProgress(const ChainTxData& data, CBlockIndex *pindex) {
+ if (pindex == NULL)
+ return 0.0;
+
+ int64_t nNow = time(NULL);
+
+ double fTxTotal;
+
+ if (pindex->nChainTx <= data.nTxCount) {
+ fTxTotal = data.nTxCount + (nNow - data.nTime) * data.dTxRate;
+ } else {
+ fTxTotal = pindex->nChainTx + (nNow - pindex->GetBlockTime()) * data.dTxRate;
+ }
+
+ return pindex->nChainTx / fTxTotal;
+}
+
class CMainCleanup
{
public:
diff --git a/src/validation.h b/src/validation.h
index f5e76c7d31..40e8907724 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -42,6 +42,7 @@ class CScriptCheck;
class CTxMemPool;
class CValidationInterface;
class CValidationState;
+struct ChainTxData;
struct PrecomputedTransactionData;
struct LockPoints;
@@ -281,6 +282,9 @@ bool GetTransaction(const uint256 &hash, CTransactionRef &tx, const Consensus::P
bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>());
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
+/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
+double GuessVerificationProgress(const ChainTxData& data, CBlockIndex* pindex);
+
/**
* Prune block and undo files (blk???.dat and undo???.dat) so that the disk space used is less than a user-defined target.
* The user sets the target (in MB) on the command line or in config file. This will be run on startup and whenever new
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 2775f4def3..86816a62e2 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1479,12 +1479,12 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
pindex = chainActive.Next(pindex);
ShowProgress(_("Rescanning..."), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
- double dProgressStart = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false);
- double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip(), false);
+ double dProgressStart = GuessVerificationProgress(chainParams.TxData(), pindex);
+ double dProgressTip = GuessVerificationProgress(chainParams.TxData(), chainActive.Tip());
while (pindex)
{
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0)
- ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
+ ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((GuessVerificationProgress(chainParams.TxData(), pindex) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
CBlock block;
ReadBlockFromDisk(block, pindex, Params().GetConsensus());
@@ -1497,7 +1497,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
pindex = chainActive.Next(pindex);
if (GetTime() >= nNow + 60) {
nNow = GetTime();
- LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex));
+ LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, GuessVerificationProgress(chainParams.TxData(), pindex));
}
}
ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI