Replace virtual methods with static attributes, chainparams.h depends on

protocol.h instead of the other way around
This commit is contained in:
jtimon
2014-06-04 12:51:29 +02:00
parent a3d946ebdc
commit c8c52de3a0
5 changed files with 53 additions and 41 deletions

View File

@@ -6,8 +6,6 @@
#include "chainparams.h"
#include "assert.h"
#include "core.h"
#include "protocol.h"
#include "util.h"
#include <boost/assign/list_of.hpp>
@@ -100,6 +98,7 @@ unsigned int pnSeed[] =
class CMainParams : public CChainParams {
public:
CMainParams() {
networkID = CChainParams::MAIN;
// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
@@ -171,27 +170,25 @@ public:
addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
vFixedSeeds.push_back(addr);
}
}
virtual const CBlock& GenesisBlock() const { return genesis; }
virtual Network NetworkID() const { return CChainParams::MAIN; }
virtual const vector<CAddress>& FixedSeeds() const {
return vFixedSeeds;
fRequireRPCPassword = true;
fMiningRequiresPeers = true;
fDefaultCheckMemPool = false;
fAllowMinDifficultyBlocks = false;
fRequireStandard = true;
fRPCisTestNet = false;
fMineBlocksOnDemand = false;
}
protected:
CBlock genesis;
vector<CAddress> vFixedSeeds;
};
static CMainParams mainParams;
//
// Testnet (v3)
//
class CTestNetParams : public CMainParams {
public:
CTestNetParams() {
networkID = CChainParams::TESTNET;
// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
@@ -223,22 +220,25 @@ public:
base58Prefixes[SECRET_KEY] = list_of(239);
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);
}
virtual bool AllowMinDifficultyBlocks() const { return true; }
virtual bool RequireStandard() const { return false; }
virtual bool RPCisTestNet() const { return true; }
virtual Network NetworkID() const { return CChainParams::TESTNET; }
fRequireRPCPassword = true;
fMiningRequiresPeers = true;
fDefaultCheckMemPool = false;
fAllowMinDifficultyBlocks = true;
fRequireStandard = false;
fRPCisTestNet = true;
fMineBlocksOnDemand = false;
}
};
static CTestNetParams testNetParams;
//
// Regression test
//
class CRegTestParams : public CTestNetParams {
public:
CRegTestParams() {
networkID = CChainParams::REGTEST;
pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0xb5;
@@ -258,14 +258,15 @@ public:
assert(hashGenesisBlock == uint256("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
vSeeds.clear(); // Regtest mode doesn't have any DNS seeds.
}
virtual bool RequireRPCPassword() const { return false; }
virtual bool MiningRequiresPeers() const { return false; }
virtual bool MineBlocksOnDemand() const { return true; }
virtual bool DefaultCheckMemPool() const { return true; }
virtual bool RequireStandard() const { return false; }
virtual Network NetworkID() const { return CChainParams::REGTEST; }
fRequireRPCPassword = false;
fMiningRequiresPeers = false;
fDefaultCheckMemPool = true;
fAllowMinDifficultyBlocks = true;
fRequireStandard = false;
fRPCisTestNet = true;
fMineBlocksOnDemand = true;
}
};
static CRegTestParams regTestParams;