Skip to content

Commit 0b1916d

Browse files
committed
Do not announce blocks (or txs) to peers when chain is stale.
1 parent 2896735 commit 0b1916d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/protocols/protocol_block_out.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,14 @@ bool protocol_block_out::handle_reorganized(code ec, size_t fork_height,
437437
return false;
438438
}
439439

440-
// Nothing to do here.
440+
// Nothing to do, a channel is stopping but it's not this one.
441441
if (!incoming)
442442
return true;
443443

444+
// Do not announce blocks to peer if too far behind.
445+
if (chain_.is_stale())
446+
return true;
447+
444448
// TODO: consider always sending the last block as compact if enabled.
445449
if (false && compact_to_peer_ && incoming->size() == 1)
446450
{

src/protocols/protocol_transaction_out.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ bool protocol_transaction_out::handle_notification(const code& ec,
245245
if (!message)
246246
return true;
247247

248+
// Do not announce transactions to peer if too far behind.
249+
// Typically the tx would not validate anyway, but this is more consistent.
250+
if (chain_.is_stale())
251+
return true;
252+
248253
if (message->validation.originator == nonce())
249254
return true;
250255

0 commit comments

Comments
 (0)