From aa27d867a2e4b4a1f7fe5de68f73c13d3b60e99e Mon Sep 17 00:00:00 2001 From: Wesley Shillingford Date: Thu, 9 Apr 2020 21:38:01 +0100 Subject: [PATCH] Use variable names for the constants (Serg review) --- nano/secure/common.cpp | 2 +- nano/secure/common.hpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/nano/secure/common.cpp b/nano/secure/common.cpp index 26c59f887d..3a60a36bd5 100644 --- a/nano/secure/common.cpp +++ b/nano/secure/common.cpp @@ -83,7 +83,7 @@ network (network_a), ledger (network), voting (network), node (network), portmap uint8_t nano::protocol_constants::protocol_version_min (bool use_epoch_2_min_version_a) const { - return use_epoch_2_min_version_a ? 0x12 : 0x11; + return use_epoch_2_min_version_a ? protocol_version_min_epoch_2 : protocol_version_min_pre_epoch_2; } nano::ledger_constants::ledger_constants (nano::network_constants & network_constants) : diff --git a/nano/secure/common.hpp b/nano/secure/common.hpp index 9bd33d813a..3f5df09150 100644 --- a/nano/secure/common.hpp +++ b/nano/secure/common.hpp @@ -353,17 +353,23 @@ class protocol_constants { public: /** Current protocol version */ - uint8_t protocol_version = 0x12; + uint8_t const protocol_version = 0x12; /** Minimum accepted protocol version */ uint8_t protocol_version_min (bool epoch_2_started) const; /** Do not request telemetry metrics to nodes older than this version */ - uint8_t telemetry_protocol_version_min = 0x12; + uint8_t const telemetry_protocol_version_min = 0x12; + +private: + /* Minimum protocol version before an epoch 2 block is seen */ + uint8_t const protocol_version_min_pre_epoch_2 = 0x11; + /* Minimum protocol version after an epoch 2 block is seen */ + uint8_t const protocol_version_min_epoch_2 = 0x12; }; -// Some places check the decltype of protocol_version instead of protocol_version_min to keep those checks simpler. This just checks it will be valid -static_assert (std::is_same::value, "protocol_min should match"); +// Some places use the decltype of protocol_version instead of protocol_version_min. To keep those checks simpler we check that the decltypes match ignoring differences in const +static_assert (std::is_same, decltype (protocol_constants ().protocol_version_min (false))>::value, "protocol_min should match"); /** Genesis keys and ledger constants for network variants */ class ledger_constants