Skip to content

Commit 3e16422

Browse files
committed
Disable tx relay at the protocol level if chain is stale.
1 parent 032694d commit 3e16422

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/protocols/protocol_transaction_in.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void protocol_transaction_in::start()
8787
}
8888

8989
// TODO: move memory_pool to a derived class protocol_transaction_in_60002.
90-
if (refresh_pool_ && relay_from_peer_)
90+
if (refresh_pool_ && relay_from_peer_ && !chain_.is_stale())
9191
{
9292
// Refresh transaction pool on connect.
9393
SEND2(memory_pool{}, handle_send, _1, memory_pool::command);
@@ -118,6 +118,11 @@ bool protocol_transaction_in::handle_receive_inventory(const code& ec,
118118
return false;
119119
}
120120

121+
// TODO: manage channel relay at the service layer.
122+
// Do not process tx inventory while chain is stale.
123+
if (chain_.is_stale())
124+
return true;
125+
121126
// Remove hashes of (unspent) transactions that we already have.
122127
// BUGBUG: this removes spent transactions which it should not (see BIP30).
123128
chain_.filter_transactions(response, BIND2(send_get_data, _1, response));
@@ -146,6 +151,7 @@ void protocol_transaction_in::send_get_data(const code& ec,
146151
// Receive transaction sequence.
147152
//-----------------------------------------------------------------------------
148153

154+
// A transaction is acceptable whether solicited or broadcast.
149155
bool protocol_transaction_in::handle_receive_transaction(const code& ec,
150156
transaction_const_ptr message)
151157
{
@@ -162,6 +168,11 @@ bool protocol_transaction_in::handle_receive_transaction(const code& ec,
162168
return false;
163169
}
164170

171+
// TODO: manage channel relay at the service layer.
172+
// Do not process transactions while chain is stale.
173+
if (chain_.is_stale())
174+
return true;
175+
165176
message->validation.originator = nonce();
166177
chain_.organize(message, BIND2(handle_store_transaction, _1, message));
167178
return true;

0 commit comments

Comments
 (0)