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

Fix infinite recursive do_notify call, comments, style. #453

Merged
merged 1 commit into from
Jan 30, 2025
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
3 changes: 1 addition & 2 deletions include/bitcoin/network/net/distributor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,11 @@ class BCT_API distributor
// Avoid deserialization if there are no subscribers for the type.
if (!subscriber.empty())
{
// Subscribers are notified only with stop code or error::success.
const auto ptr = messages::deserialize<Message>(data, version);

if (!ptr)
return error::invalid_message;

// Subscribers are notified only with stop code or error::success.
subscriber.notify(error::success, ptr);
}

Expand Down
9 changes: 7 additions & 2 deletions src/net/distributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ code distributor::do_notify<messages::block>(
distributor::block_subscriber& subscriber, uint32_t version,
const system::data_chunk& data) NOEXCEPT
{
// Avoid deserialization if there are no subscribers for the type.
if (subscriber.empty())
return error::success;

Expand All @@ -183,9 +184,13 @@ code distributor::do_notify<messages::block>(
}
else
{
return do_notify<messages::block>(subscriber, version, data);
}
const auto ptr = messages::deserialize<messages::block>(data, version);
if (!ptr)
return error::invalid_message;

// Subscribers are notified only with stop code or error::success.
subscriber.notify(error::success, ptr);
}
}

BC_POP_WARNING()
Expand Down
Loading