diff --git a/src/consensus/activation.h b/src/consensus/activation.h --- a/src/consensus/activation.h +++ b/src/consensus/activation.h @@ -35,4 +35,8 @@ bool IsPhononEnabled(const Consensus::Params ¶ms, const CBlockIndex *pindexPrev); +/** Check if November 15th, 2020 protocol upgrade has activated. */ +bool IsAxionEnabled(const Consensus::Params ¶ms, + const CBlockIndex *pindexPrev); + #endif // BITCOIN_CONSENSUS_ACTIVATION_H diff --git a/src/consensus/activation.cpp b/src/consensus/activation.cpp --- a/src/consensus/activation.cpp +++ b/src/consensus/activation.cpp @@ -71,3 +71,13 @@ return pindexPrev->GetMedianTimePast() >= gArgs.GetArg("-phononactivationtime", params.phononActivationTime); } + +bool IsAxionEnabled(const Consensus::Params ¶ms, + const CBlockIndex *pindexPrev) { + if (pindexPrev == nullptr) { + return false; + } + + return pindexPrev->GetMedianTimePast() >= + gArgs.GetArg("-axionactivationtime", params.axionActivationTime); +} diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -363,7 +363,9 @@ "-min", "-resetguisettings", "-rootcertificates=", "-splash", "-uiplatform", // TODO remove after the May 2020 upgrade - "-phononactivationtime"}; + "-phononactivationtime", + // TODO remove after the November 2020 upgrade + "-axionactivationtime"}; // Set all of the args and their help // When adding new options to the categories, please keep and ensure diff --git a/src/test/activation_tests.cpp b/src/test/activation_tests.cpp --- a/src/test/activation_tests.cpp +++ b/src/test/activation_tests.cpp @@ -67,4 +67,30 @@ BOOST_CHECK(IsPhononEnabled(params, &blocks.back())); } +BOOST_AUTO_TEST_CASE(isaxionenabled) { + CBlockIndex prev; + + const Consensus::Params ¶ms = Params().GetConsensus(); + const auto activation = + gArgs.GetArg("-axionactivationtime", params.axionActivationTime); + SetMockTime(activation - 1000000); + + BOOST_CHECK(!IsAxionEnabled(params, nullptr)); + + std::array blocks; + for (size_t i = 1; i < blocks.size(); ++i) { + blocks[i].pprev = &blocks[i - 1]; + } + BOOST_CHECK(!IsAxionEnabled(params, &blocks.back())); + + SetMTP(blocks, activation - 1); + BOOST_CHECK(!IsAxionEnabled(params, &blocks.back())); + + SetMTP(blocks, activation); + BOOST_CHECK(IsAxionEnabled(params, &blocks.back())); + + SetMTP(blocks, activation + 1); + BOOST_CHECK(IsAxionEnabled(params, &blocks.back())); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/test/lint/check-doc.py b/test/lint/check-doc.py --- a/test/lint/check-doc.py +++ b/test/lint/check-doc.py @@ -48,6 +48,8 @@ '-automaticunparking', # Remove after May 2020 upgrade '-phononactivationtime', + # Remove after November 2020 upgrade + '-axionactivationtime', '-replayprotectionactivationtime', ])