aboutsummaryrefslogtreecommitdiff
path: root/src/chainparams.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/chainparams.h')
-rw-r--r--src/chainparams.h98
1 files changed, 56 insertions, 42 deletions
diff --git a/src/chainparams.h b/src/chainparams.h
index 542afeaf92..446256ba82 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -6,22 +6,18 @@
#ifndef BITCOIN_CHAIN_PARAMS_H
#define BITCOIN_CHAIN_PARAMS_H
-#include "bignum.h"
+#include "core.h"
+#include "chainparamsbase.h"
+#include "protocol.h"
#include "uint256.h"
#include <vector>
-using namespace std;
-
-#define MESSAGE_START_SIZE 4
typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];
-class CAddress;
-class CBlock;
-
struct CDNSSeedData {
- string name, host;
- CDNSSeedData(const string &strName, const string &strHost) : name(strName), host(strHost) {}
+ std::string name, host;
+ CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
};
/**
@@ -34,14 +30,6 @@ struct CDNSSeedData {
class CChainParams
{
public:
- enum Network {
- MAIN,
- TESTNET,
- REGTEST,
-
- MAX_NETWORK_TYPES
- };
-
enum Base58Type {
PUBKEY_ADDRESS,
SCRIPT_ADDRESS,
@@ -54,32 +42,67 @@ public:
const uint256& HashGenesisBlock() const { return hashGenesisBlock; }
const MessageStartChars& MessageStart() const { return pchMessageStart; }
- const vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
+ const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
int GetDefaultPort() const { return nDefaultPort; }
- const CBigNum& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
+ const uint256& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; }
- virtual const CBlock& GenesisBlock() const = 0;
- virtual bool RequireRPCPassword() const { return true; }
- const string& DataDir() const { return strDataDir; }
- virtual Network NetworkID() const = 0;
- const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
- const std::vector<unsigned char> &Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
- virtual const vector<CAddress>& FixedSeeds() const = 0;
- int RPCPort() const { return nRPCPort; }
+ /* Used to check majorities for block version upgrade */
+ int EnforceBlockUpgradeMajority() const { return nEnforceBlockUpgradeMajority; }
+ int RejectBlockOutdatedMajority() const { return nRejectBlockOutdatedMajority; }
+ int ToCheckBlockUpgradeMajority() const { return nToCheckBlockUpgradeMajority; }
+
+ /* Used if GenerateBitcoins is called with a negative number of threads */
+ int DefaultMinerThreads() const { return nMinerThreads; }
+ const CBlock& GenesisBlock() const { return genesis; }
+ bool RequireRPCPassword() const { return fRequireRPCPassword; }
+ /* Make miner wait to have peers to avoid wasting work */
+ bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
+ /* Default value for -checkmempool argument */
+ bool DefaultCheckMemPool() const { return fDefaultCheckMemPool; }
+ /* Allow mining of a min-difficulty block */
+ bool AllowMinDifficultyBlocks() const { return fAllowMinDifficultyBlocks; }
+ /* Make standard checks */
+ bool RequireStandard() const { return fRequireStandard; }
+ int64_t TargetTimespan() const { return nTargetTimespan; }
+ int64_t TargetSpacing() const { return nTargetSpacing; }
+ int64_t Interval() const { return nTargetTimespan / nTargetSpacing; }
+ /* Make miner stop after a block is found. In RPC, don't return
+ * until nGenProcLimit blocks are generated */
+ bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
+ CBaseChainParams::Network NetworkID() const { return networkID; }
+ /* Return the BIP70 network string (main, test or regtest) */
+ std::string NetworkIDString() const { return strNetworkID; }
+ const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
+ const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
+ const std::vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
protected:
CChainParams() {}
uint256 hashGenesisBlock;
MessageStartChars pchMessageStart;
// Raw pub key bytes for the broadcast alert signing key.
- vector<unsigned char> vAlertPubKey;
+ std::vector<unsigned char> vAlertPubKey;
int nDefaultPort;
- int nRPCPort;
- CBigNum bnProofOfWorkLimit;
+ uint256 bnProofOfWorkLimit;
int nSubsidyHalvingInterval;
- string strDataDir;
- vector<CDNSSeedData> vSeeds;
+ int nEnforceBlockUpgradeMajority;
+ int nRejectBlockOutdatedMajority;
+ int nToCheckBlockUpgradeMajority;
+ int64_t nTargetTimespan;
+ int64_t nTargetSpacing;
+ int nMinerThreads;
+ std::vector<CDNSSeedData> vSeeds;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
+ CBaseChainParams::Network networkID;
+ std::string strNetworkID;
+ CBlock genesis;
+ std::vector<CAddress> vFixedSeeds;
+ bool fRequireRPCPassword;
+ bool fMiningRequiresPeers;
+ bool fDefaultCheckMemPool;
+ bool fAllowMinDifficultyBlocks;
+ bool fRequireStandard;
+ bool fMineBlocksOnDemand;
};
/**
@@ -89,7 +112,7 @@ protected:
const CChainParams &Params();
/** Sets the params returned by Params() to those for the given network. */
-void SelectParams(CChainParams::Network network);
+void SelectParams(CBaseChainParams::Network network);
/**
* Looks for -regtest or -testnet and then calls SelectParams as appropriate.
@@ -97,13 +120,4 @@ void SelectParams(CChainParams::Network network);
*/
bool SelectParamsFromCommandLine();
-inline bool TestNet() {
- // Note: it's deliberate that this returns "false" for regression test mode.
- return Params().NetworkID() == CChainParams::TESTNET;
-}
-
-inline bool RegTest() {
- return Params().NetworkID() == CChainParams::REGTEST;
-}
-
#endif