Skip to content

Commit 4554e3b

Browse files
committed
Simplify Ask block messages and fix last_hash guard.
1 parent 8a41279 commit 4554e3b

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/protocols/protocol_block_in.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ void protocol_block_in::handle_fetch_block_locator(const code& ec,
157157
if (stopped(ec))
158158
return;
159159

160-
const auto& last_hash = message->start_hashes().front();
161-
162160
if (ec)
163161
{
164162
LOG_ERROR(LOG_NODE)
@@ -171,14 +169,25 @@ void protocol_block_in::handle_fetch_block_locator(const code& ec,
171169
if (message->start_hashes().empty())
172170
return;
173171

172+
const auto& last_hash = message->start_hashes().front();
173+
174174
// TODO: move get_headers to a derived class protocol_block_in_31800.
175175
const auto use_headers = negotiated_version() >= version::level::headers;
176-
const auto default_size = use_headers ? "2000" : "500";
176+
const auto request_type = (use_headers ? "headers" : "inventory");
177177

178-
LOG_DEBUG(LOG_NODE)
179-
<< "Ask [" << authority() << "] for headers from ["
180-
<< encode_hash(last_hash) << "] through [" <<
181-
(stop_hash == null_hash ? default_size : encode_hash(stop_hash)) << "]";
178+
if (stop_hash == null_hash)
179+
{
180+
LOG_DEBUG(LOG_NODE)
181+
<< "Ask [" << authority() << "] for " << request_type << " after ["
182+
<< encode_hash(last_hash) << "]";
183+
}
184+
else
185+
{
186+
LOG_DEBUG(LOG_NODE)
187+
<< "Ask [" << authority() << "] for " << request_type << " from ["
188+
<< encode_hash(last_hash) << "] through ["
189+
<< encode_hash(stop_hash) << "]";
190+
}
182191

183192
// Save the locator top to prevent a redundant future request.
184193
last_locator_top_.store(last_hash);

0 commit comments

Comments
 (0)