From 8eed7939c72781a812fdf3fb8c36d4e3a428d268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20S=C3=A9chet?= Date: Wed, 18 Oct 2017 01:50:38 +0200 Subject: [PATCH] Next HF activation code. Summary: Fixed Nov, 13 so we are ready for whatever comes with 1x/2x . Test Plan: make check Reviewers: freetrader, dagurval, sickpig, #bitcoin_abc, schancel Reviewed By: #bitcoin_abc, schancel Subscribers: schancel Differential Revision: https://reviews.bitcoinabc.org/D612 --- src/chainparams.cpp | 9 +++++++++ src/consensus/params.h | 3 +++ src/validation.cpp | 13 +++++++++++++ src/validation.h | 3 +++ 4 files changed, 28 insertions(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6b363f868c..e5cf0335cb 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -143,6 +143,9 @@ class CMainParams : public CChainParams { // Aug, 1 hard fork consensus.uahfHeight = 478559; + // Nov, 13 hard fork + consensus.cashHardForkActivationTime = 1510600000; + /** * The message start string is designed to be unlikely to occur in * normal data. The characters are rarely used upper ASCII, not valid as @@ -312,6 +315,9 @@ class CTestNetParams : public CChainParams { // Aug, 1 hard fork consensus.uahfHeight = 1155876; + // Nov, 13 hard fork + consensus.cashHardForkActivationTime = 1510600000; + pchMessageStart[0] = 0x0b; pchMessageStart[1] = 0x11; pchMessageStart[2] = 0x09; @@ -431,6 +437,9 @@ class CRegTestParams : public CChainParams { // Hard fork is always enabled on regtest. consensus.uahfHeight = 0; + // Nov, 13 hard fork + consensus.cashHardForkActivationTime = 0; + pchMessageStart[0] = 0xfa; pchMessageStart[1] = 0xbf; pchMessageStart[2] = 0xb5; diff --git a/src/consensus/params.h b/src/consensus/params.h index ae36f4f49c..0b5ac95f13 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -73,6 +73,9 @@ struct Params { } uint256 nMinimumChainWork; uint256 defaultAssumeValid; + + /** Activation time at which the cash HF kicks in. */ + int64_t cashHardForkActivationTime; }; } // namespace Consensus diff --git a/src/validation.cpp b/src/validation.cpp index f939623b15..f82a679cf1 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -617,6 +617,19 @@ bool IsUAHFenabled(const Config &config, const CBlockIndex *pindexPrev) { return IsUAHFenabled(config, pindexPrev->nHeight); } +static bool IsCashHFEnabled(const Config &config, int64_t nMedianTimePast) { + return nMedianTimePast >= + config.GetChainParams().GetConsensus().cashHardForkActivationTime; +} + +bool IsCashHFEnabled(const Config &config, const CBlockIndex *pindexPrev) { + if (pindexPrev == nullptr) { + return false; + } + + return IsCashHFEnabled(config, pindexPrev->GetMedianTimePast()); +} + // Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool // were somehow broken and returning the wrong scriptPubKeys static bool CheckInputsFromMempoolAndCache(const CTransaction &tx, diff --git a/src/validation.h b/src/validation.h index f4ec192443..13c1e183ab 100644 --- a/src/validation.h +++ b/src/validation.h @@ -374,6 +374,9 @@ void PruneBlockFilesManual(int nPruneUpToHeight); /** Check is UAHF has activated. */ bool IsUAHFenabled(const Config &config, const CBlockIndex *pindexPrev); +/** Check is Cash HF has activated. */ +bool IsCashHFEnabled(const Config &config, const CBlockIndex *pindexPrev); + /** (try to) add transaction to memory pool * plTxnReplaced will be appended to with all transactions replaced from mempool * **/