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

Commit

Permalink
Update net_plugin.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad Shahabi committed Jan 28, 2022
1 parent 9320bdf commit d469ab2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1853,14 +1853,22 @@ namespace eosio {
//
//-----------------------------

if (head_id == msg.head_id) {
uint32_t network_latency = (std::chrono::system_clock::now().time_since_epoch().count() - msg.time); //calculating network latency ==> current_time - handshake message timestamp
uint32_t num_block_behind_by_latency = 1 + (std::chrono::milliseconds(network_latency) / std::chrono::milliseconds(config::block_interval_ms)); // Number of blocks produced during networl latency period
if (head_id == msg.head_id || ( lib_num < msg.last_irreversible_block_num && msg.last_irreversible_block_num - lib_num <= num_block_behind_by_latency)) {
peer_ilog( c, "handshake lib ${lib}, head ${head}, head id ${id}.. sync 0",
("lib", msg.last_irreversible_block_num)("head", msg.head_num)("id", msg.head_id.str().substr(8,16)) );
c->syncing = false;
notice_message note;
note.known_blocks.mode = none;
note.known_trx.mode = catch_up;
note.known_trx.pending = 0;
notice_message note;
note.known_blocks.mode = none; //block mode none
if (head_id != msg.head_id){
note.known_trx.mode = none; // transaction mode none, since it is a few blocks behind
note.known_trx.pending = head;
}
else{
note.known_trx.mode = catch_up;
note.known_trx.pending = 0;
}
c->enqueue( note );
return;
}
Expand Down

0 comments on commit d469ab2

Please sign in to comment.