From ec27d3d1f3eb29a5cab6518e24eee1c62adaa0bc Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 1 Feb 2023 15:10:23 -0600 Subject: [PATCH] GH-588 Round using lround instead of the original hardcoded +1 --- plugins/net_plugin/net_plugin.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 9bbad79e4f..61b61fdd35 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -26,6 +26,7 @@ #include #include +#include #include using namespace eosio::chain::plugin_interface; @@ -1789,8 +1790,8 @@ namespace eosio { peer_wlog(c, "Peer sent a handshake with a timestamp skewed by at least ${t}ms", ("t", network_latency_ns/1000000)); network_latency_ns = 0; } - // number of blocks syncing node is behind from a peer node - uint32_t nblk_behind_by_net_latency = static_cast(network_latency_ns / block_interval_ns); + // number of blocks syncing node is behind from a peer node, round up + uint32_t nblk_behind_by_net_latency = std::lround( static_cast(network_latency_ns) / static_cast(block_interval_ns) ); // 2x for time it takes for message to reach back to peer node uint32_t nblk_combined_latency = 2 * nblk_behind_by_net_latency; // message in the log below is used in p2p_high_latency_test.py test