@@ -403,10 +403,12 @@ namespace eosio {
403403
404404 boost::asio::deadline_timer accept_error_timer{thread_pool.get_executor ()};
405405
406-
407406 alignas (hardware_destructive_interference_sz)
408407 std::atomic<fc::time_point> head_block_time;
409408
409+ alignas (hardware_destructive_interference_sz)
410+ std::atomic<fc::time_point> last_block_received_time{};
411+
410412 struct chain_info_t {
411413 block_id_type fork_db_root_id;
412414 uint32_t fork_db_root_num = 0 ;
@@ -798,6 +800,7 @@ namespace eosio {
798800 std::atomic<uint32_t > peer_start_block_num{0 };
799801 std::atomic<uint32_t > peer_fork_db_head_block_num{0 };
800802 std::atomic<uint32_t > last_received_block_num{0 };
803+ std::atomic<fc::time_point> last_received_block_time{};
801804 std::atomic<uint32_t > unique_blocks_rcvd_count{0 };
802805 std::atomic<size_t > bytes_received{0 };
803806 std::atomic<std::chrono::nanoseconds> last_bytes_received{0ns};
@@ -1452,8 +1455,8 @@ namespace eosio {
14521455 last_block_nack = block_id_type{};
14531456 bp_connection = bp_connection_type::non_bp;
14541457
1455- uint32_t head_num = my_impl-> get_chain_head_num ();
1456- if (last_received_block_num >= head_num ) {
1458+ // if recently received a block from the connection then reset all connection block nacks
1459+ if (last_received_block_time. load () >= my_impl-> last_block_received_time . load () - fc::seconds ( 3 ) ) {
14571460 sync_manager::send_block_nack_resets ();
14581461 }
14591462
@@ -3019,7 +3022,9 @@ namespace eosio {
30193022 fc::raw::unpack ( peek_ds, bh );
30203023 const block_id_type blk_id = bh.calculate_id ();
30213024 const uint32_t blk_num = last_received_block_num = block_header::num_from_id (blk_id);
3022- const fc::microseconds age (fc::time_point::now () - bh.timestamp );
3025+ const fc::time_point now = fc::time_point::now ();
3026+ my_impl->last_block_received_time = last_received_block_time = now;
3027+ const fc::microseconds age (now - bh.timestamp );
30233028 if ( my_impl->dispatcher .have_block ( blk_id ) ) {
30243029 pending_message_buffer.advance_read_ptr ( message_length ); // advance before any send
30253030
@@ -3700,6 +3705,8 @@ namespace eosio {
37003705 if (before_lib || my_impl->dispatcher .have_block (msg.id )) {
37013706 if (block_num - 1 == block_header::num_from_id (last_block_nack)) {
37023707 ++consecutive_blocks_nacks;
3708+ } else {
3709+ consecutive_blocks_nacks = 0 ;
37033710 }
37043711 if (!before_lib) {
37053712 my_impl->dispatcher .add_peer_block (msg.id , connection_id);
0 commit comments