Skip to content

Commit

Permalink
Next HF activation code.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
deadalnix committed Oct 18, 2017
1 parent 80455aa commit 8eed793
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/chainparams.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/consensus/params.h
Expand Up @@ -73,6 +73,9 @@ struct Params {
}
uint256 nMinimumChainWork;
uint256 defaultAssumeValid;

/** Activation time at which the cash HF kicks in. */
int64_t cashHardForkActivationTime;
};
} // namespace Consensus

Expand Down
13 changes: 13 additions & 0 deletions src/validation.cpp
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/validation.h
Expand Up @@ -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
* **/
Expand Down

0 comments on commit 8eed793

Please sign in to comment.