Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10620 from EOSIO/net-plugin-bugfix
Browse files Browse the repository at this point in the history
Net plugin bugfix
  • Loading branch information
dimas1185 authored Aug 14, 2021
2 parents ff6516d + b77e326 commit db07480
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace eosio {

public:
explicit sync_manager( uint32_t span );
static void send_handshakes();
static void send_handshakes(bool force = false);
bool syncing_with_peer() const { return sync_state == lib_catchup; }
void sync_reset_lib_num( const connection_ptr& conn );
void sync_reassign_fetch( const connection_ptr& c, go_away_reason reason );
Expand Down Expand Up @@ -1725,10 +1725,10 @@ namespace eosio {
}

// static, thread safe
void sync_manager::send_handshakes() {
for_each_connection( []( auto& ci ) {
void sync_manager::send_handshakes(bool force) {
for_each_connection( [&]( auto& ci ) {
if( ci->current() ) {
ci->send_handshake();
ci->send_handshake(force);
}
return true;
} );
Expand Down Expand Up @@ -1757,7 +1757,7 @@ namespace eosio {
if( !is_sync_required( fork_head_block_num ) || target <= lib_num ) {
fc_dlog( logger, "We are already caught up, my irr = ${b}, head = ${h}, target = ${t}",
("b", lib_num)( "h", fork_head_block_num )( "t", target ) );
return;
c->send_handshake();
}

if( sync_state == in_sync ) {
Expand Down Expand Up @@ -1801,7 +1801,7 @@ namespace eosio {
// sync need checks; (lib == last irreversible block)
//
// 0. my head block id == peer head id means we are all caught up block wise
// 1. my head block num < peer lib - start sync locally
// 1. my head block num < peer lib - send handshake (if not sent in handle_message) and wait for receipt of notice message to start syncing
// 2. my lib > peer head num - send an last_irr_catch_up notice if not the first generation
//
// 3 my head block num < peer head block num - update sync state and send a catchup request
Expand All @@ -1828,6 +1828,9 @@ namespace eosio {
("ep", c->peer_name())("lib", msg.last_irreversible_block_num)("head", msg.head_num)
("id", msg.head_id.str().substr(8,16)) );
c->syncing = false;
if (c->sent_handshake_count > 0) {
c->send_handshake(true);
}
return;
}
if (lib_num > msg.head_num ) {
Expand Down Expand Up @@ -2030,18 +2033,18 @@ namespace eosio {

if( set_state_to_head_catchup ) {
if( set_state( head_catchup ) ) {
send_handshakes();
send_handshakes(true);
}
} else {
set_state( in_sync );
send_handshakes();
send_handshakes(true);
}
} else if( state == lib_catchup ) {
if( blk_num == sync_known_lib_num ) {
fc_dlog( logger, "All caught up with last known last irreversible block resending handshake" );
set_state( in_sync );
g_sync.unlock();
send_handshakes();
send_handshakes(true);
} else if( blk_num == sync_last_requested_num ) {
request_next_chunk( std::move( g_sync) );
} else {
Expand Down

0 comments on commit db07480

Please sign in to comment.