Skip to content

Commit

Permalink
Make stats and parse status enums compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jan 25, 2024
1 parent dd78fa6 commit 703b8c5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions nano/core_test/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,16 +796,16 @@ TEST (network, duplicate_detection)
auto & node1 = *system.add_node (node_flags);
nano::publish publish{ nano::dev::network_params.network, nano::dev::genesis };

ASSERT_EQ (0, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish));
ASSERT_EQ (0, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish_message));

// Publish duplicate detection through TCP
auto tcp_channel = node0.network.tcp_channels.find_node_id (node1.get_node_id ());
ASSERT_NE (nullptr, tcp_channel);
ASSERT_EQ (0, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish));
ASSERT_EQ (0, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish_message));
tcp_channel->send (publish);
ASSERT_TIMELY_EQ (2s, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish), 0);
ASSERT_TIMELY_EQ (2s, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish_message), 0);
tcp_channel->send (publish);
ASSERT_TIMELY_EQ (2s, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish), 1);
ASSERT_TIMELY_EQ (2s, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish_message), 1);
}

TEST (network, duplicate_revert_publish)
Expand Down
6 changes: 4 additions & 2 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ enum class detail : uint8_t
broadcast,
cleanup,
top,
none,
success,

// processing queue
queue,
Expand Down Expand Up @@ -172,7 +174,7 @@ enum class detail : uint8_t
invalid_frontier_req_message,
invalid_asc_pull_req_message,
invalid_asc_pull_ack_message,
message_too_big,
message_size_too_big,
outdated_version,

// tcp
Expand Down Expand Up @@ -210,7 +212,7 @@ enum class detail : uint8_t
requests_unknown,

// duplicate
duplicate_publish,
duplicate_publish_message,

// telemetry
invalid_signature,
Expand Down
4 changes: 2 additions & 2 deletions nano/node/transport/message_deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ nano::stat::detail nano::to_stat_detail (nano::transport::message_deserializer::
return stat::detail::outdated_version;
break;
case parse_status::duplicate_publish_message:
return stat::detail::duplicate_publish;
return stat::detail::duplicate_publish_message;
break;
case parse_status::message_size_too_big:
return stat::detail::message_too_big;
return stat::detail::message_size_too_big;
break;
}
return {};
Expand Down
2 changes: 1 addition & 1 deletion nano/node/transport/tcp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ void nano::transport::tcp_server::received_message (std::unique_ptr<nano::messag
node->stats.inc (nano::stat::type::error, nano::to_stat_detail (message_deserializer->status));
if (message_deserializer->status == transport::message_deserializer::parse_status::duplicate_publish_message)
{
node->stats.inc (nano::stat::type::filter, nano::stat::detail::duplicate_publish);
node->stats.inc (nano::stat::type::filter, nano::stat::detail::duplicate_publish_message);
}
else
{
Expand Down

0 comments on commit 703b8c5

Please sign in to comment.