diff --git a/rai/core_test/message.cpp b/rai/core_test/message.cpp index 83fcc070..a847caf8 100644 --- a/rai/core_test/message.cpp +++ b/rai/core_test/message.cpp @@ -42,9 +42,6 @@ TEST (message, publish_serialization) { rai::publish publish (std::make_shared (0, 1, 2, rai::keypair ().prv, 4, 5)); ASSERT_EQ (rai::block_type::send, publish.header.block_type ()); - ASSERT_FALSE (publish.header.ipv4_only ()); - publish.header.ipv4_only_set (true); - ASSERT_TRUE (publish.header.ipv4_only ()); std::vector bytes; { rai::vectorstream stream (bytes); @@ -57,7 +54,7 @@ TEST (message, publish_serialization) ASSERT_EQ (rai::protocol_version, bytes[3]); ASSERT_EQ (rai::protocol_version_min, bytes[4]); ASSERT_EQ (static_cast (rai::message_type::publish), bytes[5]); - ASSERT_EQ (0x02, bytes[6]); + ASSERT_EQ (0x00, bytes[6]); // extensions ASSERT_EQ (static_cast (rai::block_type::send), bytes[7]); rai::bufferstream stream (bytes.data (), bytes.size ()); auto error (false); diff --git a/rai/node/common.cpp b/rai/node/common.cpp index 221e5d7f..8c0d6a31 100644 --- a/rai/node/common.cpp +++ b/rai/node/common.cpp @@ -5,8 +5,6 @@ #include std::array constexpr rai::message_header::magic_number; -size_t constexpr rai::message_header::ipv4_only_position; -size_t constexpr rai::message_header::bootstrap_server_position; std::bitset<16> constexpr rai::message_header::block_type_mask; rai::message_header::message_header (rai::message_type type_a) : @@ -74,16 +72,6 @@ void rai::message_header::block_type_set (rai::block_type type_a) extensions |= std::bitset<16> (static_cast (type_a) << 8); } -bool rai::message_header::ipv4_only () -{ - return extensions.test (ipv4_only_position); -} - -void rai::message_header::ipv4_only_set (bool value_a) -{ - extensions.set (ipv4_only_position, value_a); -} - // MTU - IP header - UDP header const size_t rai::message_parser::max_safe_udp_message_size = 508; @@ -742,11 +730,11 @@ response (response) { if (query) { - header.extensions.set (query_flag); + set_query_flag (true); } if (response) { - header.extensions.set (response_flag); + set_response_flag (true); } } @@ -754,7 +742,7 @@ bool rai::node_id_handshake::deserialize (rai::stream & stream_a) { auto result (false); assert (header.type == rai::message_type::node_id_handshake); - if (!result && header.extensions.test (query_flag)) + if (!result && is_query_flag ()) { rai::uint256_union query_hash; result = read (stream_a, query_hash); @@ -763,7 +751,7 @@ bool rai::node_id_handshake::deserialize (rai::stream & stream_a) query = query_hash; } } - if (!result && header.extensions.test (response_flag)) + if (!result && is_response_flag ()) { rai::account response_account; result = read (stream_a, response_account); @@ -800,6 +788,26 @@ bool rai::node_id_handshake::operator== (rai::node_id_handshake const & other_a) return result; } +bool rai::node_id_handshake::is_query_flag () const +{ + return header.extensions.test (query_flag); +} + +void rai::node_id_handshake::set_query_flag (bool value_a) +{ + header.extensions.set (query_flag, value_a); +} + +bool rai::node_id_handshake::is_response_flag () const +{ + return header.extensions.test (response_flag); +} + +void rai::node_id_handshake::set_response_flag (bool value_a) +{ + header.extensions.set (response_flag, value_a); +} + void rai::node_id_handshake::visit (rai::message_visitor & visitor_a) const { visitor_a.node_id_handshake (*this); diff --git a/rai/node/common.hpp b/rai/node/common.hpp index 6a6651a9..8c720f58 100644 --- a/rai/node/common.hpp +++ b/rai/node/common.hpp @@ -164,16 +164,14 @@ public: bool deserialize (rai::stream &); rai::block_type block_type () const; void block_type_set (rai::block_type); - bool ipv4_only (); - void ipv4_only_set (bool); static std::array constexpr magic_number = rai::rai_network == rai::rai_networks::rai_test_network ? std::array{ { 'R', 'A' } } : rai::rai_network == rai::rai_networks::rai_beta_network ? std::array{ { 'R', 'B' } } : std::array{ { 'R', 'C' } }; uint8_t version_max; uint8_t version_using; uint8_t version_min; rai::message_type type; std::bitset<16> extensions; - static size_t constexpr ipv4_only_position = 1; - static size_t constexpr bootstrap_server_position = 2; + //static size_t constexpr ipv4_only_position = 1; // Not in use, deprecated, was conflicting + //static size_t constexpr bootstrap_server_position = 2; // Not in use, deprecated static std::bitset<16> constexpr block_type_mask = std::bitset<16> (0x0f00); inline bool valid_magic () const { @@ -347,6 +345,10 @@ public: void serialize (rai::stream &) const override; void visit (rai::message_visitor &) const override; bool operator== (rai::node_id_handshake const &) const; + bool is_query_flag () const; + void set_query_flag (bool); + bool is_response_flag () const; + void set_response_flag (bool); boost::optional query; boost::optional> response; static size_t constexpr query_flag = 0;