aboutsummaryrefslogtreecommitdiff
path: root/src/deploymentstatus.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-08-01 18:36:43 +1000
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-08-20 10:36:41 +0300
commit57fce067a322d4b30ae8516795d5d2a1fe2f9f66 (patch)
treeadd90613bcf48874e3956e9e021e32d11a4455eb /src/deploymentstatus.cpp
parente9d30fbb3a90dfafebdb026a53b4f632614d660e (diff)
downloadbitcoin-57fce067a322d4b30ae8516795d5d2a1fe2f9f66.tar.xz
consensus/params: simplify ValidDeployment check to avoid gcc warning
Github-Pull: bitcoin/bitcoin#22597 Rebased-From: 059171009b0138555f311cedc2553015ff618323
Diffstat (limited to 'src/deploymentstatus.cpp')
-rw-r--r--src/deploymentstatus.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/deploymentstatus.cpp b/src/deploymentstatus.cpp
index 9007800421..bba86639a3 100644
--- a/src/deploymentstatus.cpp
+++ b/src/deploymentstatus.cpp
@@ -7,6 +7,8 @@
#include <consensus/params.h>
#include <versionbits.h>
+#include <type_traits>
+
VersionBitsCache g_versionbitscache;
/* Basic sanity checking for BuriedDeployment/DeploymentPos enums and
@@ -15,3 +17,18 @@ VersionBitsCache g_versionbitscache;
static_assert(ValidDeployment(Consensus::DEPLOYMENT_TESTDUMMY), "sanity check of DeploymentPos failed (TESTDUMMY not valid)");
static_assert(!ValidDeployment(Consensus::MAX_VERSION_BITS_DEPLOYMENTS), "sanity check of DeploymentPos failed (MAX value considered valid)");
static_assert(!ValidDeployment(static_cast<Consensus::BuriedDeployment>(Consensus::DEPLOYMENT_TESTDUMMY)), "sanity check of BuriedDeployment failed (overlaps with DeploymentPos)");
+
+/* ValidDeployment only checks upper bounds for ensuring validity.
+ * This checks that the lowest possible value or the type is also a
+ * (specific) valid deployment so that lower bounds don't need to be checked.
+ */
+
+template<typename T, T x>
+static constexpr bool is_minimum()
+{
+ using U = typename std::underlying_type<T>::type;
+ return x == std::numeric_limits<U>::min();
+}
+
+static_assert(is_minimum<Consensus::BuriedDeployment, Consensus::DEPLOYMENT_HEIGHTINCB>(), "heightincb is not minimum value for BuriedDeployment");
+static_assert(is_minimum<Consensus::DeploymentPos, Consensus::DEPLOYMENT_TESTDUMMY>(), "testdummy is not minimum value for DeploymentPos");