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

deduplicate notifications code #1806

Merged
merged 3 commits into from
Sep 28, 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
52 changes: 22 additions & 30 deletions core/network/impl/peer_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,37 +705,29 @@ namespace kagome::network {

log_->trace("Try to open outgoing validation protocol.(peer={})",
peer_info.id);
openOutgoing(
stream_engine_,
validation_protocol,
peer_info,
[validation_protocol, peer_info, wptr{weak_from_this()}](
auto &&stream_result) {
auto self = wptr.lock();
if (not self) {
return;
}

auto &peer_id = peer_info.id;
if (!stream_result.has_value()) {
self->log_->warn("Unable to create stream {} with {}: {}",
validation_protocol->protocolName(),
peer_id,
stream_result.error().message());
return;
}
openOutgoing(stream_engine_,
validation_protocol,
peer_info,
[validation_protocol, peer_info, wptr{weak_from_this()}](
outcome::result<std::shared_ptr<Stream>> stream_result) {
auto self = wptr.lock();
if (not self) {
return;
}

auto &peer_id = peer_info.id;
if (!stream_result.has_value()) {
self->log_->warn(
"Unable to create stream {} with {}: {}",
validation_protocol->protocolName(),
peer_id,
stream_result.error().message());
return;
}

if (auto res = self->stream_engine_->addOutgoing(
stream_result.value(), validation_protocol);
!res) {
SL_VERBOSE(self->log_,
"Can't register outgoing {} stream with {}: {}",
validation_protocol->protocolName(),
stream_result.value()->remotePeerId().value(),
res.error().message());
stream_result.value()->reset();
}
});
self->stream_engine_->addOutgoing(stream_result.value(),
validation_protocol);
});
}
}

Expand Down
Loading