Skip to content

Commit bc9783d

Browse files
committed
Implement conditional compile for block allocator.
1 parent 2e1f35f commit bc9783d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

include/bitcoin/network/net/distributor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class BCT_API distributor
113113
const system::data_chunk& data) NOEXCEPT
114114
{
115115
// Avoid deserialization if there are no subscribers for the type.
116-
if (!is_zero(subscriber.size()))
116+
if (!subscriber.empty())
117117
{
118118
// Subscribers are notified only with stop code or error::success.
119119
const auto ptr = messages::deserialize<Message>(data, version);

src/net/distributor.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include <bitcoin/network/memory.hpp>
2424
#include <bitcoin/network/messages/messages.hpp>
2525

26+
// Set false to use default block allocation.
27+
constexpr bool use_block_allocator = true;
28+
2629
namespace libbitcoin {
2730
namespace network {
2831

@@ -159,7 +162,10 @@ code distributor::do_notify<messages::block>(
159162
distributor::block_subscriber& subscriber, uint32_t version,
160163
const system::data_chunk& data) NOEXCEPT
161164
{
162-
if (!is_zero(subscriber.size()))
165+
if (subscriber.empty())
166+
return error::success;
167+
168+
if constexpr (use_block_allocator)
163169
{
164170
const auto arena = memory_.get_arena();
165171
if (arena == nullptr)
@@ -170,9 +176,12 @@ code distributor::do_notify<messages::block>(
170176
return error::invalid_message;
171177

172178
subscriber.notify(error::success, ptr);
179+
return error::success;
180+
}
181+
else
182+
{
183+
return do_notify<messages::block>(subscriber, version, data);
173184
}
174-
175-
return error::success;
176185
}
177186

178187
#undef SUBSCRIBER

0 commit comments

Comments
 (0)