Skip to content

Commit 7a90b1f

Browse files
authored
Merge pull request #453 from evoskuil/master
Fix infinite recursive do_notify call, comments, style.
2 parents 1833aa6 + 6bf606e commit 7a90b1f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

include/bitcoin/network/net/distributor.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,11 @@ class BCT_API distributor
115115
// Avoid deserialization if there are no subscribers for the type.
116116
if (!subscriber.empty())
117117
{
118-
// Subscribers are notified only with stop code or error::success.
119118
const auto ptr = messages::deserialize<Message>(data, version);
120-
121119
if (!ptr)
122120
return error::invalid_message;
123121

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

src/net/distributor.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ code distributor::do_notify<messages::block>(
165165
distributor::block_subscriber& subscriber, uint32_t version,
166166
const system::data_chunk& data) NOEXCEPT
167167
{
168+
// Avoid deserialization if there are no subscribers for the type.
168169
if (subscriber.empty())
169170
return error::success;
170171

@@ -183,9 +184,13 @@ code distributor::do_notify<messages::block>(
183184
}
184185
else
185186
{
186-
return do_notify<messages::block>(subscriber, version, data);
187-
}
187+
const auto ptr = messages::deserialize<messages::block>(data, version);
188+
if (!ptr)
189+
return error::invalid_message;
188190

191+
// Subscribers are notified only with stop code or error::success.
192+
subscriber.notify(error::success, ptr);
193+
}
189194
}
190195

191196
BC_POP_WARNING()

0 commit comments

Comments
 (0)