Skip to content

Commit 1a8b668

Browse files
committed
Integrate new optimizing block message.
1 parent ee24c63 commit 1a8b668

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/protocols/protocol_block_out_106.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <chrono>
2222
#include <bitcoin/node/define.hpp>
23+
#include <bitcoin/node/messages/messages.hpp>
2324

2425
namespace libbitcoin {
2526
namespace node {
@@ -158,7 +159,7 @@ bool protocol_block_out_106::handle_receive_get_data(const code& ec,
158159
return true;
159160

160161
const auto total = ceilinged_add(backlog_.size(), size);
161-
if (total > messages::peer::max_inventory)
162+
if (total > network::messages::peer::max_inventory)
162163
{
163164
LOGR("Blocks requested (" << total << ") exceeds inv limit ["
164165
<< opposite() << "].");
@@ -210,8 +211,10 @@ void protocol_block_out_106::send_block(const code& ec) NOEXCEPT
210211

211212
const auto& query = archive();
212213
const auto start = logger::now();
213-
const auto ptr = query.get_block(query.to_header(item.hash), witness);
214-
if (!ptr)
214+
const auto link = query.to_header(item.hash);
215+
216+
node::messages::block out{ query.get_wire_block(link, witness), witness };
217+
if (out.block_data.empty())
215218
{
216219
LOGR("Requested block " << encode_hash(item.hash) << " from ["
217220
<< opposite() << "] not found.");
@@ -223,7 +226,7 @@ void protocol_block_out_106::send_block(const code& ec) NOEXCEPT
223226

224227
backlog_.pop_front();
225228
span<microseconds>(events::block_usecs, start);
226-
SEND(messages::peer::block{ ptr }, send_block, _1);
229+
SEND(std::move(out), send_block, _1);
227230
}
228231

229232
// utilities
@@ -247,7 +250,7 @@ protocol_block_out_106::inventory protocol_block_out_106::create_inventory(
247250
return inventory::factory
248251
(
249252
archive().get_blocks(locator.start_hashes, locator.stop_hash,
250-
messages::peer::max_get_blocks), type_id::block
253+
network::messages::peer::max_get_blocks), type_id::block
251254
);
252255
}
253256

0 commit comments

Comments
 (0)