Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to allow reconnection to SHiP endpoints after connection lost. #3

Merged
merged 3 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

elmato marked this conversation as resolved.
Show resolved Hide resolved
// 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