Skip to content

Commit

Permalink
GH-2102 Fix sync issue with receiving a current block while syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Apr 4, 2024
1 parent 2e49794 commit 4c3535f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2540,7 +2540,11 @@ namespace eosio {
if (sync_last_requested_num == 0) { // block was rejected
sync_next_expected_num = my_impl->get_chain_lib_num() + 1;
} else {
sync_next_expected_num = blk_num + 1;
if (blk_num == sync_next_expected_num) {
++sync_next_expected_num;
} else if (blk_num < sync_next_expected_num) {
sync_next_expected_num = blk_num + 1;
}
}
}

Expand Down Expand Up @@ -3140,14 +3144,14 @@ namespace eosio {
}
} else {
block_sync_bytes_received += message_length;
my_impl->sync_master->sync_recv_block(shared_from_this(), blk_id, blk_num, false);
uint32_t lib_num = my_impl->get_chain_lib_num();
if( blk_num <= lib_num ) {
cancel_wait();

pending_message_buffer.advance_read_ptr( message_length );
return true;
}
my_impl->sync_master->sync_recv_block(shared_from_this(), blk_id, blk_num, false);
}

auto ds = pending_message_buffer.create_datastream();
Expand Down

0 comments on commit 4c3535f

Please sign in to comment.