diff options
| author | Ross Nicoll <[email protected]> | 2017-12-28 15:04:08 +0000 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2018-09-19 19:24:06 +0100 |
| commit | 1be681a1b97b686f838af90682a57f2030d26015 (patch) | |
| tree | b2795e4a1d35004dbfd84d49b07bc54413a2a9e1 /src/chainparams.h | |
| parent | Change BIP65/66 enforcement to match Dogecoin (#1403) (diff) | |
| download | discoin-1be681a1b97b686f838af90682a57f2030d26015.tar.xz discoin-1be681a1b97b686f838af90682a57f2030d26015.zip | |
Modify chain consensus parameters to be height aware (#1396)
* Modify chain consensus parameters to be height aware
* Correct implementation of simplified rewards in parameters
* Correct max money
* Use base block version in IsSuperMajority() instead of full version
* Correct mining of blocks in AuxPoW tests
* Add in missing pre-AuxPoW consensus checks
Diffstat (limited to 'src/chainparams.h')
| -rw-r--r-- | src/chainparams.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/chainparams.h b/src/chainparams.h index 22843b886..14ceff4c7 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -56,7 +56,24 @@ public: MAX_BASE58_TYPES }; - const Consensus::Params& GetConsensus() const { return consensus; } + const Consensus::Params& GetConsensus(uint32_t nTargetHeight) const { + return *GetConsensus(nTargetHeight, pConsensusRoot); + } + + Consensus::Params *GetConsensus(uint32_t nTargetHeight, Consensus::Params *pRoot) const { + if (nTargetHeight < pRoot -> nHeightEffective && pRoot -> pLeft != NULL) { + return GetConsensus(nTargetHeight, pRoot -> pLeft); + } else if (nTargetHeight > pRoot -> nHeightEffective && pRoot -> pRight != NULL) { + Consensus::Params *pCandidate = GetConsensus(nTargetHeight, pRoot -> pRight); + if (pCandidate->nHeightEffective <= nTargetHeight) { + return pCandidate; + } + } + + // No better match below the target height + return pRoot; + } + const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; } int GetDefaultPort() const { return nDefaultPort; } @@ -82,6 +99,7 @@ protected: CChainParams() {} Consensus::Params consensus; + Consensus::Params *pConsensusRoot; // Binary search tree root CMessageHeader::MessageStartChars pchMessageStart; int nDefaultPort; uint64_t nPruneAfterHeight; |