Skip to content

Commit

Permalink
Use variable names for the constants (Serg review)
Browse files Browse the repository at this point in the history
  • Loading branch information
wezrule committed Apr 9, 2020
1 parent 8d8fa53 commit aa27d86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nano/secure/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) :
Expand Down
14 changes: 10 additions & 4 deletions nano/secure/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<decltype (protocol_constants ().protocol_version), decltype (protocol_constants ().protocol_version_min (false))>::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<std::remove_const_t<decltype (protocol_constants ().protocol_version)>, decltype (protocol_constants ().protocol_version_min (false))>::value, "protocol_min should match");

/** Genesis keys and ledger constants for network variants */
class ledger_constants
Expand Down

0 comments on commit aa27d86

Please sign in to comment.