Consensus: Refactor: Introduce Consensus::Params class
This commit is contained in:
parent
cbb2cf5522
commit
bd006110fb
4 changed files with 70 additions and 49 deletions
|
@ -6,11 +6,12 @@
|
|||
#ifndef BITCOIN_CHAINPARAMS_H
|
||||
#define BITCOIN_CHAINPARAMS_H
|
||||
|
||||
#include "arith_uint256.h"
|
||||
#include "chainparamsbase.h"
|
||||
#include "checkpoints.h"
|
||||
#include "consensus/params.h"
|
||||
#include "primitives/block.h"
|
||||
#include "protocol.h"
|
||||
#include "arith_uint256.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -39,16 +40,16 @@ public:
|
|||
MAX_BASE58_TYPES
|
||||
};
|
||||
|
||||
const uint256& HashGenesisBlock() const { return hashGenesisBlock; }
|
||||
const Consensus::Params& GetConsensus() const { return consensus; }
|
||||
const uint256& HashGenesisBlock() const { return consensus.hashGenesisBlock; }
|
||||
const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
|
||||
const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
|
||||
int GetDefaultPort() const { return nDefaultPort; }
|
||||
const arith_uint256& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
|
||||
int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; }
|
||||
/** Used to check majorities for block version upgrade */
|
||||
int EnforceBlockUpgradeMajority() const { return nEnforceBlockUpgradeMajority; }
|
||||
int RejectBlockOutdatedMajority() const { return nRejectBlockOutdatedMajority; }
|
||||
int ToCheckBlockUpgradeMajority() const { return nToCheckBlockUpgradeMajority; }
|
||||
const arith_uint256& ProofOfWorkLimit() const { return consensus.powLimit; }
|
||||
int SubsidyHalvingInterval() const { return consensus.nSubsidyHalvingInterval; }
|
||||
int EnforceBlockUpgradeMajority() const { return consensus.nMajorityEnforceBlockUpgrade; }
|
||||
int RejectBlockOutdatedMajority() const { return consensus.nMajorityRejectBlockOutdated; }
|
||||
int ToCheckBlockUpgradeMajority() const { return consensus.nMajorityWindow; }
|
||||
|
||||
/** Used if GenerateBitcoins is called with a negative number of threads */
|
||||
int DefaultMinerThreads() const { return nMinerThreads; }
|
||||
|
@ -59,12 +60,12 @@ public:
|
|||
/** Default value for -checkmempool argument */
|
||||
bool DefaultCheckMemPool() const { return fDefaultCheckMemPool; }
|
||||
/** Allow mining of a min-difficulty block */
|
||||
bool AllowMinDifficultyBlocks() const { return fAllowMinDifficultyBlocks; }
|
||||
bool AllowMinDifficultyBlocks() const { return consensus.fPowAllowMinDifficultyBlocks; }
|
||||
/** Make standard checks */
|
||||
bool RequireStandard() const { return fRequireStandard; }
|
||||
int64_t TargetTimespan() const { return nTargetTimespan; }
|
||||
int64_t TargetSpacing() const { return nTargetSpacing; }
|
||||
int64_t DifficultyAdjustmentInterval() const { return nTargetTimespan / nTargetSpacing; }
|
||||
int64_t TargetTimespan() const { return consensus.nPowTargetTimespan; }
|
||||
int64_t TargetSpacing() const { return consensus.nPowTargetSpacing; }
|
||||
int64_t DifficultyAdjustmentInterval() const { return consensus.nPowTargetTimespan / consensus.nPowTargetSpacing; }
|
||||
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
|
||||
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
|
||||
/** In the future use NetworkIDString() for RPC fields */
|
||||
|
@ -78,18 +79,11 @@ public:
|
|||
protected:
|
||||
CChainParams() {}
|
||||
|
||||
uint256 hashGenesisBlock;
|
||||
Consensus::Params consensus;
|
||||
CMessageHeader::MessageStartChars pchMessageStart;
|
||||
//! Raw pub key bytes for the broadcast alert signing key.
|
||||
std::vector<unsigned char> vAlertPubKey;
|
||||
int nDefaultPort;
|
||||
arith_uint256 bnProofOfWorkLimit;
|
||||
int nSubsidyHalvingInterval;
|
||||
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];
|
||||
|
@ -99,7 +93,6 @@ protected:
|
|||
bool fRequireRPCPassword;
|
||||
bool fMiningRequiresPeers;
|
||||
bool fDefaultCheckMemPool;
|
||||
bool fAllowMinDifficultyBlocks;
|
||||
bool fRequireStandard;
|
||||
bool fMineBlocksOnDemand;
|
||||
bool fTestnetToBeDeprecatedFieldRPC;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue