Browse Source

Merge pull request #6242

17221bf chainparams: don't use std namespace (Cory Fields)
f0deec5 chainparams: move CCheckpointData into chainparams.h (Cory Fields)
0.13
Wladimir J. van der Laan 9 years ago
parent
commit
e3f13ddc54
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 10
      src/chainparams.cpp
  2. 13
      src/chainparams.h
  3. 9
      src/checkpoints.h
  4. 2
      src/test/Checkpoints_tests.cpp

10
src/chainparams.cpp

@ -12,8 +12,6 @@
#include <boost/assign/list_of.hpp> #include <boost/assign/list_of.hpp>
using namespace std;
#include "chainparamsseeds.h" #include "chainparamsseeds.h"
static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
@ -22,7 +20,7 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
txNew.nVersion = 1; txNew.nVersion = 1;
txNew.vin.resize(1); txNew.vin.resize(1);
txNew.vout.resize(1); txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = genesisReward; txNew.vout[0].nValue = genesisReward;
txNew.vout[0].scriptPubKey = genesisOutputScript; txNew.vout[0].scriptPubKey = genesisOutputScript;
@ -117,7 +115,7 @@ public:
fMineBlocksOnDemand = false; fMineBlocksOnDemand = false;
fTestnetToBeDeprecatedFieldRPC = false; fTestnetToBeDeprecatedFieldRPC = false;
checkpointData = (Checkpoints::CCheckpointData) { checkpointData = (CCheckpointData) {
boost::assign::map_list_of boost::assign::map_list_of
( 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ( 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
( 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) ( 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))
@ -190,7 +188,7 @@ public:
fMineBlocksOnDemand = false; fMineBlocksOnDemand = false;
fTestnetToBeDeprecatedFieldRPC = true; fTestnetToBeDeprecatedFieldRPC = true;
checkpointData = (Checkpoints::CCheckpointData) { checkpointData = (CCheckpointData) {
boost::assign::map_list_of boost::assign::map_list_of
( 546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")), ( 546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")),
1337966069, 1337966069,
@ -239,7 +237,7 @@ public:
fMineBlocksOnDemand = true; fMineBlocksOnDemand = true;
fTestnetToBeDeprecatedFieldRPC = false; fTestnetToBeDeprecatedFieldRPC = false;
checkpointData = (Checkpoints::CCheckpointData){ checkpointData = (CCheckpointData){
boost::assign::map_list_of boost::assign::map_list_of
( 0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")), ( 0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")),
0, 0,

13
src/chainparams.h

@ -7,7 +7,6 @@
#define BITCOIN_CHAINPARAMS_H #define BITCOIN_CHAINPARAMS_H
#include "chainparamsbase.h" #include "chainparamsbase.h"
#include "checkpoints.h"
#include "consensus/params.h" #include "consensus/params.h"
#include "primitives/block.h" #include "primitives/block.h"
#include "protocol.h" #include "protocol.h"
@ -24,6 +23,14 @@ struct SeedSpec6 {
uint16_t port; 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 * CChainParams defines various tweakable parameters of a given instance of the
@ -67,7 +74,7 @@ public:
const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; } const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; } const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; } const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
const Checkpoints::CCheckpointData& Checkpoints() const { return checkpointData; } const CCheckpointData& Checkpoints() const { return checkpointData; }
protected: protected:
CChainParams() {} CChainParams() {}
@ -87,7 +94,7 @@ protected:
bool fRequireStandard; bool fRequireStandard;
bool fMineBlocksOnDemand; bool fMineBlocksOnDemand;
bool fTestnetToBeDeprecatedFieldRPC; bool fTestnetToBeDeprecatedFieldRPC;
Checkpoints::CCheckpointData checkpointData; CCheckpointData checkpointData;
}; };
/** /**

9
src/checkpoints.h

@ -10,6 +10,7 @@
#include <map> #include <map>
class CBlockIndex; class CBlockIndex;
struct CCheckpointData;
/** /**
* Block-chain checkpoints are compiled-in sanity checks. * Block-chain checkpoints are compiled-in sanity checks.
@ -17,14 +18,6 @@ class CBlockIndex;
*/ */
namespace Checkpoints 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 //! Return conservative estimate of total number of blocks, 0 if unknown
int GetTotalBlocksEstimate(const CCheckpointData& data); int GetTotalBlocksEstimate(const CCheckpointData& data);

2
src/test/Checkpoints_tests.cpp

@ -20,7 +20,7 @@ BOOST_FIXTURE_TEST_SUITE(Checkpoints_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(sanity) 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); BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate(checkpoints) >= 134444);
} }

Loading…
Cancel
Save