Skip to content

Commit

Permalink
chainparams: move CCheckpointData into chainparams.h
Browse files Browse the repository at this point in the history
This unties CChainParams from its dependency on checkpoints. Instead, now it
only depends on the raw checkpoint data.
  • Loading branch information
theuni committed Jul 28, 2015
1 parent eddaba7 commit f0deec5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CMainParams : public CChainParams {
fMineBlocksOnDemand = false;
fTestnetToBeDeprecatedFieldRPC = false;

checkpointData = (Checkpoints::CCheckpointData) {
checkpointData = (CCheckpointData) {
boost::assign::map_list_of
( 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
( 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))
Expand Down Expand Up @@ -189,7 +189,7 @@ class CTestNetParams : public CChainParams {
fMineBlocksOnDemand = false;
fTestnetToBeDeprecatedFieldRPC = true;

checkpointData = (Checkpoints::CCheckpointData) {
checkpointData = (CCheckpointData) {
boost::assign::map_list_of
( 546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")),
1337966069,
Expand Down Expand Up @@ -235,7 +235,7 @@ class CRegTestParams : public CChainParams {
fMineBlocksOnDemand = true;
fTestnetToBeDeprecatedFieldRPC = false;

checkpointData = (Checkpoints::CCheckpointData){
checkpointData = (CCheckpointData){
boost::assign::map_list_of
( 0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")),
0,
Expand Down
13 changes: 10 additions & 3 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#define BITCOIN_CHAINPARAMS_H

#include "chainparamsbase.h"
#include "checkpoints.h"
#include "consensus/params.h"
#include "primitives/block.h"
#include "protocol.h"
Expand All @@ -24,6 +23,14 @@ struct SeedSpec6 {
uint16_t port;
};

typedef std::map<int, uint256> MapCheckpoints;

struct CCheckpointData {
MapCheckpoints mapCheckpoints;
int64_t nTimeLastCheckpoint;
int64_t nTransactionsLastCheckpoint;
double fTransactionsPerDay;
};

/**
* CChainParams defines various tweakable parameters of a given instance of the
Expand Down Expand Up @@ -67,7 +74,7 @@ class CChainParams
const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
const Checkpoints::CCheckpointData& Checkpoints() const { return checkpointData; }
const CCheckpointData& Checkpoints() const { return checkpointData; }
protected:
CChainParams() {}

Expand All @@ -87,7 +94,7 @@ class CChainParams
bool fRequireStandard;
bool fMineBlocksOnDemand;
bool fTestnetToBeDeprecatedFieldRPC;
Checkpoints::CCheckpointData checkpointData;
CCheckpointData checkpointData;
};

/**
Expand Down
9 changes: 1 addition & 8 deletions src/checkpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,14 @@
#include <map>

class CBlockIndex;
struct CCheckpointData;

/**
* Block-chain checkpoints are compiled-in sanity checks.
* They are updated every release or three.
*/
namespace Checkpoints
{
typedef std::map<int, uint256> MapCheckpoints;

struct CCheckpointData {
MapCheckpoints mapCheckpoints;
int64_t nTimeLastCheckpoint;
int64_t nTransactionsLastCheckpoint;
double fTransactionsPerDay;
};

//! Return conservative estimate of total number of blocks, 0 if unknown
int GetTotalBlocksEstimate(const CCheckpointData& data);
Expand Down
2 changes: 1 addition & 1 deletion src/test/Checkpoints_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BOOST_FIXTURE_TEST_SUITE(Checkpoints_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(sanity)
{
const Checkpoints::CCheckpointData& checkpoints = Params(CBaseChainParams::MAIN).Checkpoints();
const CCheckpointData& checkpoints = Params(CBaseChainParams::MAIN).Checkpoints();
BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate(checkpoints) >= 134444);
}

Expand Down

0 comments on commit f0deec5

Please sign in to comment.