Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115071
D12289.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D12289.diff
View Options
diff --git a/src/consensus/params.h b/src/consensus/params.h
--- a/src/consensus/params.h
+++ b/src/consensus/params.h
@@ -24,7 +24,7 @@
};
constexpr bool ValidDeployment(BuriedDeployment dep) {
- return DEPLOYMENT_P2SH <= dep && dep <= DEPLOYMENT_CSV;
+ return dep <= DEPLOYMENT_CSV;
}
enum DeploymentPos : uint16_t {
@@ -34,7 +34,7 @@
MAX_VERSION_BITS_DEPLOYMENTS,
};
constexpr bool ValidDeployment(DeploymentPos dep) {
- return DEPLOYMENT_TESTDUMMY <= dep && dep < MAX_VERSION_BITS_DEPLOYMENTS;
+ return dep < MAX_VERSION_BITS_DEPLOYMENTS;
}
/**
diff --git a/src/deploymentstatus.cpp b/src/deploymentstatus.cpp
--- 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;
/**
@@ -23,3 +25,21 @@
!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_P2SH>(),
+ "p2sh is not minimum value for BuriedDeployment");
+static_assert(
+ is_minimum<Consensus::DeploymentPos, Consensus::DEPLOYMENT_TESTDUMMY>(),
+ "testdummy is not minimum value for DeploymentPos");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 09:34 (1 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187221
Default Alt Text
D12289.diff (1 KB)
Attached To
D12289: simplify ValidDeployment check to avoid gcc warning
Event Timeline
Log In to Comment