Skip to content

Commit bfda15f

Browse files
committed
Consensus: Incomplete: Cleanup: remove Consensus::Params getters from CChainParams
1 parent 0cecb8a commit bfda15f

File tree

5 files changed

+6
-19
lines changed

5 files changed

+6
-19
lines changed

src/chainparams.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,9 @@ class CChainParams
4343
};
4444

4545
const Consensus::Params& GetConsensus() const { return consensus; }
46-
const uint256& HashGenesisBlock() const { return consensus.hashGenesisBlock; }
4746
const MessageStartChars& MessageStart() const { return pchMessageStart; }
4847
const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
4948
int GetDefaultPort() const { return nDefaultPort; }
50-
const arith_uint256& ProofOfWorkLimit() const { return consensus.powLimit; }
51-
int SubsidyHalvingInterval() const { return consensus.nSubsidyHalvingInterval; }
52-
int EnforceBlockUpgradeMajority() const { return consensus.nMajorityEnforceBlockUpgrade; }
53-
int RejectBlockOutdatedMajority() const { return consensus.nMajorityRejectBlockOutdated; }
54-
int ToCheckBlockUpgradeMajority() const { return consensus.nMajorityWindow; }
5549

5650
/** Used if GenerateBitcoins is called with a negative number of threads */
5751
int DefaultMinerThreads() const { return nMinerThreads; }
@@ -61,15 +55,8 @@ class CChainParams
6155
bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
6256
/** Default value for -checkmempool argument */
6357
bool DefaultCheckMemPool() const { return fDefaultCheckMemPool; }
64-
/** Allow mining of a min-difficulty block */
65-
bool AllowMinDifficultyBlocks() const { return consensus.fPowAllowMinDifficultyBlocks; }
66-
/** Skip proof-of-work check: allow mining of any difficulty block */
67-
bool SkipProofOfWorkCheck() const { return consensus.fPowSkipProofOfWorkCheck; }
6858
/** Make standard checks */
6959
bool RequireStandard() const { return fRequireStandard; }
70-
int64_t TargetTimespan() const { return consensus.nPowTargetTimespan; }
71-
int64_t TargetSpacing() const { return consensus.nPowTargetSpacing; }
72-
int64_t Interval() const { return consensus.nPowTargetTimespan / consensus.nPowTargetSpacing; }
7360
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
7461
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
7562
/** In the future use NetworkIDString() for RPC fields */

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ bool AppInit2(boost::thread_group& threadGroup)
10541054

10551055
// If the loaded chain has a wrong genesis, bail out immediately
10561056
// (we're likely using a testnet datadir, or the other way around).
1057-
if (!mapBlockIndex.empty() && mapBlockIndex.count(Params().HashGenesisBlock()) == 0)
1057+
if (!mapBlockIndex.empty() && mapBlockIndex.count(Params().GetConsensus().hashGenesisBlock) == 0)
10581058
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
10591059

10601060
// Initialize the block index (no-op if non-empty database was already loaded)

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,7 +3368,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
33683368
// not a direct successor.
33693369
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexBestHeader), inv.hash);
33703370
CNodeState *nodestate = State(pfrom->GetId());
3371-
if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - Params().TargetSpacing() * 20 &&
3371+
if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - Params().GetConsensus().nPowTargetSpacing * 20 &&
33723372
nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
33733373
vToFetch.push_back(inv);
33743374
// Mark block as in flight already, even though the actual "getdata" message only goes out
@@ -4217,7 +4217,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
42174217
// timeout. We compensate for in-flight blocks to prevent killing off peers due to our own downstream link
42184218
// being saturated. We only count validated in-flight blocks so peers can't advertize nonexisting block hashes
42194219
// to unreasonably increase our timeout.
4220-
if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0 && state.vBlocksInFlight.front().nTime < nNow - 500000 * Params().TargetSpacing() * (4 + state.vBlocksInFlight.front().nValidatedQueuedBefore)) {
4220+
if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0 && state.vBlocksInFlight.front().nTime < nNow - 500000 * Params().GetConsensus().nPowTargetSpacing * (4 + state.vBlocksInFlight.front().nValidatedQueuedBefore)) {
42214221
LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", state.vBlocksInFlight.front().hash.ToString(), pto->id);
42224222
pto->fDisconnect = true;
42234223
}

src/miner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void UpdateTime(CBlockHeader* pblock, const CBlockIndex* pindexPrev)
8383
pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
8484

8585
// Updating time can change work required on testnet:
86-
if (Params().AllowMinDifficultyBlocks())
86+
if (Params().GetConsensus().fPowAllowMinDifficultyBlocks)
8787
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
8888
}
8989

@@ -521,7 +521,7 @@ void static BitcoinMiner(CWallet *pwallet)
521521

522522
// Update nTime every few seconds
523523
UpdateTime(pblock, pindexPrev);
524-
if (Params().AllowMinDifficultyBlocks())
524+
if (Params().GetConsensus().fPowAllowMinDifficultyBlocks)
525525
{
526526
// Changing pblock->nTime can change work required on testnet:
527527
hashTarget.SetCompact(pblock->nBits);

src/rpcmining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Value GetNetworkHashPS(int lookup, int height) {
4444

4545
// If lookup is -1, then use blocks since last difficulty change.
4646
if (lookup <= 0)
47-
lookup = pb->nHeight % Params().Interval() + 1;
47+
lookup = pb->nHeight % Params().GetConsensus().Interval() + 1;
4848

4949
// If lookup is larger than chain, then set it to chain length.
5050
if (lookup > pb->nHeight)

0 commit comments

Comments
 (0)