Replace virtual methods with static attributes, chainparams.h depends on
protocol.h instead of the other way around
This commit is contained in:
parent
a3d946ebdc
commit
c8c52de3a0
5 changed files with 53 additions and 41 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "alert.h"
|
#include "alert.h"
|
||||||
|
|
||||||
|
#include "chainparams.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
#include "chainparams.h"
|
#include "chainparams.h"
|
||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "core.h"
|
|
||||||
#include "protocol.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <boost/assign/list_of.hpp>
|
#include <boost/assign/list_of.hpp>
|
||||||
|
@ -100,6 +98,7 @@ unsigned int pnSeed[] =
|
||||||
class CMainParams : public CChainParams {
|
class CMainParams : public CChainParams {
|
||||||
public:
|
public:
|
||||||
CMainParams() {
|
CMainParams() {
|
||||||
|
networkID = CChainParams::MAIN;
|
||||||
// The message start string is designed to be unlikely to occur in normal data.
|
// 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
|
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
|
||||||
// a large 4-byte int at any alignment.
|
// a large 4-byte int at any alignment.
|
||||||
|
@ -171,27 +170,25 @@ public:
|
||||||
addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
|
addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
|
||||||
vFixedSeeds.push_back(addr);
|
vFixedSeeds.push_back(addr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
virtual const CBlock& GenesisBlock() const { return genesis; }
|
fRequireRPCPassword = true;
|
||||||
virtual Network NetworkID() const { return CChainParams::MAIN; }
|
fMiningRequiresPeers = true;
|
||||||
|
fDefaultCheckMemPool = false;
|
||||||
virtual const vector<CAddress>& FixedSeeds() const {
|
fAllowMinDifficultyBlocks = false;
|
||||||
return vFixedSeeds;
|
fRequireStandard = true;
|
||||||
|
fRPCisTestNet = false;
|
||||||
|
fMineBlocksOnDemand = false;
|
||||||
}
|
}
|
||||||
protected:
|
|
||||||
CBlock genesis;
|
|
||||||
vector<CAddress> vFixedSeeds;
|
|
||||||
};
|
};
|
||||||
static CMainParams mainParams;
|
static CMainParams mainParams;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Testnet (v3)
|
// Testnet (v3)
|
||||||
//
|
//
|
||||||
class CTestNetParams : public CMainParams {
|
class CTestNetParams : public CMainParams {
|
||||||
public:
|
public:
|
||||||
CTestNetParams() {
|
CTestNetParams() {
|
||||||
|
networkID = CChainParams::TESTNET;
|
||||||
// The message start string is designed to be unlikely to occur in normal data.
|
// 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
|
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
|
||||||
// a large 4-byte int at any alignment.
|
// a large 4-byte int at any alignment.
|
||||||
|
@ -223,22 +220,25 @@ public:
|
||||||
base58Prefixes[SECRET_KEY] = list_of(239);
|
base58Prefixes[SECRET_KEY] = list_of(239);
|
||||||
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
|
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
|
||||||
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);
|
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool AllowMinDifficultyBlocks() const { return true; }
|
fRequireRPCPassword = true;
|
||||||
virtual bool RequireStandard() const { return false; }
|
fMiningRequiresPeers = true;
|
||||||
virtual bool RPCisTestNet() const { return true; }
|
fDefaultCheckMemPool = false;
|
||||||
virtual Network NetworkID() const { return CChainParams::TESTNET; }
|
fAllowMinDifficultyBlocks = true;
|
||||||
|
fRequireStandard = false;
|
||||||
|
fRPCisTestNet = true;
|
||||||
|
fMineBlocksOnDemand = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static CTestNetParams testNetParams;
|
static CTestNetParams testNetParams;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Regression test
|
// Regression test
|
||||||
//
|
//
|
||||||
class CRegTestParams : public CTestNetParams {
|
class CRegTestParams : public CTestNetParams {
|
||||||
public:
|
public:
|
||||||
CRegTestParams() {
|
CRegTestParams() {
|
||||||
|
networkID = CChainParams::REGTEST;
|
||||||
pchMessageStart[0] = 0xfa;
|
pchMessageStart[0] = 0xfa;
|
||||||
pchMessageStart[1] = 0xbf;
|
pchMessageStart[1] = 0xbf;
|
||||||
pchMessageStart[2] = 0xb5;
|
pchMessageStart[2] = 0xb5;
|
||||||
|
@ -258,14 +258,15 @@ public:
|
||||||
assert(hashGenesisBlock == uint256("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
|
assert(hashGenesisBlock == uint256("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
|
||||||
|
|
||||||
vSeeds.clear(); // Regtest mode doesn't have any DNS seeds.
|
vSeeds.clear(); // Regtest mode doesn't have any DNS seeds.
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool RequireRPCPassword() const { return false; }
|
fRequireRPCPassword = false;
|
||||||
virtual bool MiningRequiresPeers() const { return false; }
|
fMiningRequiresPeers = false;
|
||||||
virtual bool MineBlocksOnDemand() const { return true; }
|
fDefaultCheckMemPool = true;
|
||||||
virtual bool DefaultCheckMemPool() const { return true; }
|
fAllowMinDifficultyBlocks = true;
|
||||||
virtual bool RequireStandard() const { return false; }
|
fRequireStandard = false;
|
||||||
virtual Network NetworkID() const { return CChainParams::REGTEST; }
|
fRPCisTestNet = true;
|
||||||
|
fMineBlocksOnDemand = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static CRegTestParams regTestParams;
|
static CRegTestParams regTestParams;
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,15 @@
|
||||||
#define BITCOIN_CHAIN_PARAMS_H
|
#define BITCOIN_CHAIN_PARAMS_H
|
||||||
|
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
|
#include "core.h"
|
||||||
|
#include "protocol.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define MESSAGE_START_SIZE 4
|
|
||||||
typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];
|
typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];
|
||||||
|
|
||||||
class CAddress;
|
|
||||||
class CBlock;
|
|
||||||
|
|
||||||
struct CDNSSeedData {
|
struct CDNSSeedData {
|
||||||
string name, host;
|
string name, host;
|
||||||
CDNSSeedData(const string &strName, const string &strHost) : name(strName), host(strHost) {}
|
CDNSSeedData(const string &strName, const string &strHost) : name(strName), host(strHost) {}
|
||||||
|
@ -64,26 +62,26 @@ public:
|
||||||
|
|
||||||
/* Used if GenerateBitcoins is called with a negative number of threads */
|
/* Used if GenerateBitcoins is called with a negative number of threads */
|
||||||
int DefaultMinerThreads() const { return nMinerThreads; }
|
int DefaultMinerThreads() const { return nMinerThreads; }
|
||||||
virtual const CBlock& GenesisBlock() const = 0;
|
const CBlock& GenesisBlock() const { return genesis; };
|
||||||
virtual bool RequireRPCPassword() const { return true; }
|
bool RequireRPCPassword() const { return fRequireRPCPassword; }
|
||||||
/* Make miner wait to have peers to avoid wasting work */
|
/* Make miner wait to have peers to avoid wasting work */
|
||||||
virtual bool MiningRequiresPeers() const { return true; }
|
bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
|
||||||
/* Default value for -checkmempool argument */
|
/* Default value for -checkmempool argument */
|
||||||
virtual bool DefaultCheckMemPool() const { return false; }
|
bool DefaultCheckMemPool() const { return fDefaultCheckMemPool; }
|
||||||
/* Allow mining of a min-difficulty block */
|
/* Allow mining of a min-difficulty block */
|
||||||
virtual bool AllowMinDifficultyBlocks() const { return false; }
|
bool AllowMinDifficultyBlocks() const { return fAllowMinDifficultyBlocks; }
|
||||||
/* Make standard checks */
|
/* Make standard checks */
|
||||||
virtual bool RequireStandard() const { return true; }
|
bool RequireStandard() const { return fRequireStandard; }
|
||||||
/* Make standard checks */
|
/* Make standard checks */
|
||||||
virtual bool RPCisTestNet() const { return false; }
|
bool RPCisTestNet() const { return fRPCisTestNet; }
|
||||||
const string& DataDir() const { return strDataDir; }
|
const string& DataDir() const { return strDataDir; }
|
||||||
/* Make miner stop after a block is found. In RPC, don't return
|
/* Make miner stop after a block is found. In RPC, don't return
|
||||||
* until nGenProcLimit blocks are generated */
|
* until nGenProcLimit blocks are generated */
|
||||||
virtual bool MineBlocksOnDemand() const { return false; }
|
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
|
||||||
virtual Network NetworkID() const = 0;
|
Network NetworkID() const { return networkID; }
|
||||||
const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
|
const 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]; }
|
||||||
virtual const vector<CAddress>& FixedSeeds() const = 0;
|
const vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
|
||||||
int RPCPort() const { return nRPCPort; }
|
int RPCPort() const { return nRPCPort; }
|
||||||
protected:
|
protected:
|
||||||
CChainParams() {}
|
CChainParams() {}
|
||||||
|
@ -103,6 +101,16 @@ protected:
|
||||||
int nMinerThreads;
|
int nMinerThreads;
|
||||||
vector<CDNSSeedData> vSeeds;
|
vector<CDNSSeedData> vSeeds;
|
||||||
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
||||||
|
Network networkID;
|
||||||
|
CBlock genesis;
|
||||||
|
vector<CAddress> vFixedSeeds;
|
||||||
|
bool fRequireRPCPassword;
|
||||||
|
bool fMiningRequiresPeers;
|
||||||
|
bool fDefaultCheckMemPool;
|
||||||
|
bool fAllowMinDifficultyBlocks;
|
||||||
|
bool fRequireStandard;
|
||||||
|
bool fRPCisTestNet;
|
||||||
|
bool fMineBlocksOnDemand;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
|
#include "chainparams.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#ifndef __INCLUDED_PROTOCOL_H__
|
#ifndef __INCLUDED_PROTOCOL_H__
|
||||||
#define __INCLUDED_PROTOCOL_H__
|
#define __INCLUDED_PROTOCOL_H__
|
||||||
|
|
||||||
#include "chainparams.h"
|
|
||||||
#include "netbase.h"
|
#include "netbase.h"
|
||||||
#include "serialize.h"
|
#include "serialize.h"
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
|
@ -19,6 +18,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#define MESSAGE_START_SIZE 4
|
||||||
|
|
||||||
/** Message header.
|
/** Message header.
|
||||||
* (4) message start.
|
* (4) message start.
|
||||||
* (12) command.
|
* (12) command.
|
||||||
|
|
Loading…
Reference in a new issue