Skip to content

Commit

Permalink
Merge pull request #3 from eosnetworkfoundation/yarkin/ship_reconnection
Browse files Browse the repository at this point in the history
Refactor to allow reconnection to SHiP endpoints after connection lost.
  • Loading branch information
yarkinwho committed Aug 9, 2023
2 parents f406fa4 + 2f15b8d commit ca81bb1
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 70 deletions.
8 changes: 8 additions & 0 deletions src/block_conversion_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ class block_conversion_plugin_impl : std::enable_shared_from_this<block_conversi

SILK_WARN << "Can't link new block " << *new_block;

// Double check if it's duplicated ones.
// We do not need to import block again during reconnection if it's in this cache.
auto dup_block = std::find_if(native_blocks.begin(), native_blocks.end(), [&new_block](const auto& nb){ return nb.id == new_block->id; });
if( dup_block != native_blocks.end() ) {
SILK_WARN << "Receiving duplicated blocks " << new_block->id << " It's normal if it's caused by reconnection to SHiP.";
return;
}

// Find fork block
auto fork_block = std::find_if(native_blocks.begin(), native_blocks.end(), [&new_block](const auto& nb){ return nb.id == new_block->prev; });
if( fork_block == native_blocks.end() ) {
Expand Down
Loading

0 comments on commit ca81bb1

Please sign in to comment.