Skip to content

Commit

Permalink
Merge pull request #2007 from AntelopeIO/GH-2006-unlinkable-blocks-5.0
Browse files Browse the repository at this point in the history
[5.0] Fix unlinkable block exceptions when block-log-retain-blocks = 0
  • Loading branch information
heifner authored Dec 20, 2023
2 parents a469b69 + 468aad6 commit 89e2db1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3062,7 +3062,7 @@ namespace eosio {
("h", my_impl->get_chain_head_num()));
if( !my_impl->sync_master->syncing_from_peer() ) { // guard against peer thinking it needs to send us old blocks
uint32_t lib_num = my_impl->get_chain_lib_num();
if( blk_num < lib_num ) {
if( blk_num <= lib_num ) {
fc::unique_lock g( conn_mtx );
const auto last_sent_lib = last_handshake_sent.last_irreversible_block_num;
g.unlock();
Expand All @@ -3079,6 +3079,13 @@ 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;
}
}

auto ds = pending_message_buffer.create_datastream();
Expand Down Expand Up @@ -3740,7 +3747,7 @@ namespace eosio {
connection_ptr c = shared_from_this();

try {
if( cc.fetch_block_by_id(blk_id) ) {
if( blk_num <= cc.last_irreversible_block_num() || cc.fetch_block_by_id(blk_id) ) {
c->strand.post( [sync_master = my_impl->sync_master.get(),
dispatcher = my_impl->dispatcher.get(), c, blk_id, blk_num]() {
dispatcher->add_peer_block( blk_id, c->connection_id );
Expand Down

0 comments on commit 89e2db1

Please sign in to comment.