|
|
|
@ -14,13 +14,25 @@ namespace Checkpoints
|
|
|
|
|
{
|
|
|
|
|
typedef std::map<int, uint256> MapCheckpoints;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// How many times we expect transactions after the last checkpoint to
|
|
|
|
|
// be slower. This number is conservative. On multi-core CPUs with
|
|
|
|
|
// parallel signature checking enabled, this number is way too high.
|
|
|
|
|
// We prefer a progressbar that's faster at the end than the other
|
|
|
|
|
// way around, though.
|
|
|
|
|
static const double fSigcheckVerificationFactor = 15.0;
|
|
|
|
|
|
|
|
|
|
struct CCheckpointData {
|
|
|
|
|
const MapCheckpoints *mapCheckpoints;
|
|
|
|
|
int64 nTimeLastCheckpoint;
|
|
|
|
|
int64 nTransactionsLastCheckpoint;
|
|
|
|
|
double fTransactionsPerDay;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// What makes a good checkpoint block?
|
|
|
|
|
// + Is surrounded by blocks with reasonable timestamps
|
|
|
|
|
// (no blocks before with a timestamp after, none after with
|
|
|
|
|
// timestamp before)
|
|
|
|
|
// + Contains no strange transactions
|
|
|
|
|
//
|
|
|
|
|
static MapCheckpoints mapCheckpoints =
|
|
|
|
|
boost::assign::map_list_of
|
|
|
|
|
( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
|
|
|
|
@ -33,30 +45,81 @@ namespace Checkpoints
|
|
|
|
|
(210000, uint256("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e"))
|
|
|
|
|
(216116, uint256("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e"))
|
|
|
|
|
;
|
|
|
|
|
static const CCheckpointData data = {
|
|
|
|
|
&mapCheckpoints,
|
|
|
|
|
1357902690, // * UNIX timestamp of last checkpoint block
|
|
|
|
|
11011160, // * total number of transactions between genesis and last checkpoint
|
|
|
|
|
// (the tx=... number in the SetBestChain debug.log lines)
|
|
|
|
|
50000.0 // * estimated number of transactions per day after checkpoint
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static MapCheckpoints mapCheckpointsTestnet =
|
|
|
|
|
boost::assign::map_list_of
|
|
|
|
|
( 546, uint256("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70"))
|
|
|
|
|
;
|
|
|
|
|
static const CCheckpointData dataTestnet = {
|
|
|
|
|
&mapCheckpointsTestnet,
|
|
|
|
|
1338180505,
|
|
|
|
|
16341,
|
|
|
|
|
300
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CCheckpointData &Checkpoints() {
|
|
|
|
|
if (fTestNet)
|
|
|
|
|
return dataTestnet;
|
|
|
|
|
else
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CheckBlock(int nHeight, const uint256& hash)
|
|
|
|
|
{
|
|
|
|
|
if (!GetBoolArg("-checkpoints", true))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
|
|
|
|
|
const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;
|
|
|
|
|
|
|
|
|
|
MapCheckpoints::const_iterator i = checkpoints.find(nHeight);
|
|
|
|
|
if (i == checkpoints.end()) return true;
|
|
|
|
|
return hash == i->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Guess how far we are in the verification process at the given block index
|
|
|
|
|
double GuessVerificationProgress(CBlockIndex *pindex) {
|
|
|
|
|
if (pindex==NULL)
|
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
|
|
int64 nNow = time(NULL);
|
|
|
|
|
|
|
|
|
|
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 checkoint, and
|
|
|
|
|
// fSigcheckVerificationFactor per transaction after.
|
|
|
|
|
|
|
|
|
|
const CCheckpointData &data = Checkpoints();
|
|
|
|
|
|
|
|
|
|
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->nTime)/86400.0*data.fTransactionsPerDay;
|
|
|
|
|
fWorkBefore = nCheapBefore + nExpensiveBefore*fSigcheckVerificationFactor;
|
|
|
|
|
fWorkAfter = nExpensiveAfter*fSigcheckVerificationFactor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fWorkBefore / (fWorkBefore + fWorkAfter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int GetTotalBlocksEstimate()
|
|
|
|
|
{
|
|
|
|
|
if (!GetBoolArg("-checkpoints", true))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
|
|
|
|
|
const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;
|
|
|
|
|
|
|
|
|
|
return checkpoints.rbegin()->first;
|
|
|
|
|
}
|
|
|
|
@ -66,7 +129,7 @@ namespace Checkpoints
|
|
|
|
|
if (!GetBoolArg("-checkpoints", true))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
|
|
|
|
|
const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;
|
|
|
|
|
|
|
|
|
|
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints)
|
|
|
|
|
{
|
|
|
|
|