Skip to content

Commit 08c089c

Browse files
committed
GH-1660 Treat catchup sync diff than peer sync. Do not disconnect on fork switch.
1 parent 7dedf09 commit 08c089c

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

plugins/net_plugin/net_plugin.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,9 @@ namespace eosio {
547547

548548
struct peer_sync_state {
549549
enum class sync_t {
550-
peer_sync, // LIB or head catchup, syncing request_message:catch_up
551-
block_nack // sync due to block nack (block_notice_message) request_message:normal
550+
peer_sync, // sync_request_message, syncing
551+
peer_catchup, // head catchup, syncing request_message:catch_up
552+
block_nack // sync due to block nack (block_notice_message) request_message:normal
552553
};
553554
peer_sync_state(uint32_t start, uint32_t end, uint32_t last_acted, sync_t sync_type)
554555
:start_block( start ), end_block( end ), last( last_acted ), sync_type( sync_type )
@@ -1489,7 +1490,7 @@ namespace eosio {
14891490

14901491
auto msg_head_num = block_header::num_from_id(msg_head_id);
14911492
if (msg_head_num == 0) {
1492-
blk_send_branch( msg_head_num, fork_db_root_num, head_num, peer_sync_state::sync_t::peer_sync );
1493+
blk_send_branch( msg_head_num, fork_db_root_num, head_num, peer_sync_state::sync_t::peer_catchup );
14931494
return;
14941495
}
14951496

@@ -1502,7 +1503,7 @@ namespace eosio {
15021503
// if peer on fork, start at their last fork_db_root_num, otherwise we can start at msg_head+1
15031504
if (on_fork)
15041505
msg_head_num = 0;
1505-
blk_send_branch( msg_head_num, fork_db_root_num, head_num, peer_sync_state::sync_t::peer_sync );
1506+
blk_send_branch( msg_head_num, fork_db_root_num, head_num, peer_sync_state::sync_t::peer_catchup );
15061507
}
15071508
}
15081509

@@ -1537,8 +1538,7 @@ namespace eosio {
15371538
}
15381539
if( peer_requested->valid() ) {
15391540
peer_ilog( this, "enqueue ${t} ${s} - ${e}",
1540-
("t", sync_type == peer_sync_state::sync_t::peer_sync ? "peer" : "block")
1541-
("s", peer_requested->start_block)("e", peer_requested->end_block) );
1541+
("t", sync_type)("s", peer_requested->start_block)("e", peer_requested->end_block) );
15421542
enqueue_sync_block();
15431543
} else {
15441544
peer_ilog( this, "nothing to enqueue" );
@@ -1760,7 +1760,7 @@ namespace eosio {
17601760
block_sync_frame_bytes_sent = 0;
17611761
peer_dlog( this, "completing enqueue_sync_block ${num}", ("num", num) );
17621762
}
1763-
} else if (peer_requested->sync_type == peer_sync_state::sync_t::block_nack) {
1763+
} else if (peer_requested->sync_type == peer_sync_state::sync_t::peer_catchup || peer_requested->sync_type == peer_sync_state::sync_t::block_nack) {
17641764
// Do not have the block, likely because in the middle of a fork-switch. A fork-switch will send out
17651765
// block_notice_message for the new blocks. Ignore, similar to the ignore in blk_send_branch().
17661766
peer_ilog( this, "enqueue block sync, unable to fetch block ${num}, resetting peer request", ("num", num) );
@@ -5062,3 +5062,5 @@ namespace eosio {
50625062
start_conn_timer( connector_period, {}, timer_type::stats );
50635063
}
50645064
} // namespace eosio
5065+
5066+
FC_REFLECT_ENUM( eosio::peer_sync_state::sync_t, (peer_sync)(peer_catchup)(block_nack) )

0 commit comments

Comments
 (0)