Skip to content

Commit 148f769

Browse files
committed
Revert block orphan scaveging (recursion, not worth the code).
1 parent 62c5270 commit 148f769

File tree

2 files changed

+7
-44
lines changed

2 files changed

+7
-44
lines changed

include/bitcoin/node/protocols/protocol_block_in.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ class BCN_API protocol_block_in
5858
bool handle_receive_inventory(const code& ec, inventory_const_ptr message);
5959
bool handle_receive_not_found(const code& ec, not_found_const_ptr message);
6060
void handle_store_block(const code& ec, block_const_ptr message);
61-
void handle_orphan_block(const code& ec, size_t position,
62-
block_const_ptr message);
6361
void handle_fetch_block_locator(const code& ec, get_headers_ptr message,
6462
const hash_digest& stop_hash);
6563

src/protocols/protocol_block_in.cpp

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -324,39 +324,6 @@ bool protocol_block_in::handle_receive_block(const code& ec,
324324
return true;
325325
}
326326

327-
void protocol_block_in::handle_orphan_block(const code& ec,
328-
size_t position, block_const_ptr message)
329-
{
330-
if (stopped(ec))
331-
return;
332-
333-
const auto& txs = message->transactions();
334-
335-
if (!ec && position > 0)
336-
{
337-
BITCOIN_ASSERT(position < txs.size());
338-
const auto encoded = encode_hash(txs[position].hash());
339-
340-
LOG_DEBUG(LOG_NODE)
341-
<< "Scavenged transaction [" << encoded << "] from ["
342-
<< authority() << "].";
343-
}
344-
345-
// Start by incrementing past the presumed coinbase, and so-on.
346-
if (++position >= txs.size())
347-
{
348-
// Ask the peer for blocks from the chain top up to this orphan.
349-
send_get_blocks(message->hash());
350-
return;
351-
}
352-
353-
// TODO: store txs in shared pointer list within block.
354-
auto tx = std::make_shared<const message::transaction>(txs[position]);
355-
356-
// Recursion is broken up by the organizer's priority pool transition.
357-
chain_.organize(tx, BIND3(handle_orphan_block, _1, position, message));
358-
}
359-
360327
// The block has been saved to the block chain (or not).
361328
// This will be picked up by subscription in block_out and will cause the block
362329
// to be announced to non-originating peers.
@@ -367,18 +334,16 @@ void protocol_block_in::handle_store_block(const code& ec,
367334
return;
368335

369336
const auto hash = message->header().hash();
370-
const auto encoded = encode_hash(hash);
371337

338+
// Ask the peer for blocks from the chain top up to this orphan.
372339
if (ec == error::orphan_block)
373-
{
374-
LOG_DEBUG(LOG_NODE)
375-
<< "Scavenging orphan block [" << encoded << "] from ["
376-
<< authority() << "]";
377-
handle_orphan_block(error::success, 0, message);
378-
return;
379-
}
340+
send_get_blocks(hash);
341+
342+
const auto encoded = encode_hash(hash);
380343

381-
if (ec == error::duplicate_block || ec == error::insufficient_work)
344+
if (ec == error::orphan_block ||
345+
ec == error::duplicate_block ||
346+
ec == error::insufficient_work)
382347
{
383348
LOG_DEBUG(LOG_NODE)
384349
<< "Captured block [" << encoded << "] from [" << authority()

0 commit comments

Comments
 (0)