Skip to content

Commit 622e3c9

Browse files
committed
Merge pull request #5999
e8e8904 Chainparams: Cleanup: Delete CChainParams getters to attributes from Consensus::Params (Jorge Timón)
2 parents 4c4f1b4 + e8e8904 commit 622e3c9

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/chainparams.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class CChainParams
4444
const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
4545
const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
4646
int GetDefaultPort() const { return nDefaultPort; }
47-
const uint256& ProofOfWorkLimit() const { return consensus.powLimit; }
4847
int SubsidyHalvingInterval() const { return consensus.nSubsidyHalvingInterval; }
4948
int EnforceBlockUpgradeMajority() const { return consensus.nMajorityEnforceBlockUpgrade; }
5049
int RejectBlockOutdatedMajority() const { return consensus.nMajorityRejectBlockOutdated; }
@@ -62,9 +61,6 @@ class CChainParams
6261
bool AllowMinDifficultyBlocks() const { return consensus.fPowAllowMinDifficultyBlocks; }
6362
/** Make standard checks */
6463
bool RequireStandard() const { return fRequireStandard; }
65-
int64_t TargetTimespan() const { return consensus.nPowTargetTimespan; }
66-
int64_t TargetSpacing() const { return consensus.nPowTargetSpacing; }
67-
int64_t DifficultyAdjustmentInterval() const { return consensus.nPowTargetTimespan / consensus.nPowTargetSpacing; }
6864
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
6965
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
7066
/** In the future use NetworkIDString() for RPC fields */

src/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,6 +3577,7 @@ void static ProcessGetData(CNode* pfrom)
35773577

35783578
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived)
35793579
{
3580+
const CChainParams& chainparams = Params();
35803581
RandAddSeedPerfmon();
35813582
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
35823583
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
@@ -3836,7 +3837,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
38363837
// not a direct successor.
38373838
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexBestHeader), inv.hash);
38383839
CNodeState *nodestate = State(pfrom->GetId());
3839-
if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - Params().TargetSpacing() * 20 &&
3840+
if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - chainparams.GetConsensus().nPowTargetSpacing * 20 &&
38403841
nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
38413842
vToFetch.push_back(inv);
38423843
// Mark block as in flight already, even though the actual "getdata" message only goes out
@@ -4499,6 +4500,7 @@ bool ProcessMessages(CNode* pfrom)
44994500

45004501
bool SendMessages(CNode* pto, bool fSendTrickle)
45014502
{
4503+
const Consensus::Params& consensusParams = Params().GetConsensus();
45024504
{
45034505
// Don't send anything until we get their version message
45044506
if (pto->nVersion == 0)
@@ -4686,7 +4688,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
46864688
// timeout. We compensate for in-flight blocks to prevent killing off peers due to our own downstream link
46874689
// being saturated. We only count validated in-flight blocks so peers can't advertize nonexisting block hashes
46884690
// to unreasonably increase our timeout.
4689-
if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0 && state.vBlocksInFlight.front().nTime < nNow - 500000 * Params().TargetSpacing() * (4 + state.vBlocksInFlight.front().nValidatedQueuedBefore)) {
4691+
if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0 && state.vBlocksInFlight.front().nTime < nNow - 500000 * consensusParams.nPowTargetSpacing * (4 + state.vBlocksInFlight.front().nValidatedQueuedBefore)) {
46904692
LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", state.vBlocksInFlight.front().hash.ToString(), pto->id);
46914693
pto->fDisconnect = true;
46924694
}

src/rpcmining.cpp

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

4646
// If lookup is -1, then use blocks since last difficulty change.
4747
if (lookup <= 0)
48-
lookup = pb->nHeight % Params().DifficultyAdjustmentInterval() + 1;
48+
lookup = pb->nHeight % Params().GetConsensus().DifficultyAdjustmentInterval() + 1;
4949

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

0 commit comments

Comments
 (0)