Merge 58e02395ba into merged_master (Bitcoin PR bitcoin/bitcoin#22955)

This commit is contained in:
Byron Hambly 2023-04-21 11:43:16 +00:00
commit 965ac7c53b
3 changed files with 25 additions and 15 deletions

View file

@ -2960,13 +2960,13 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
return;
}
// We won't accept tx inv's if we're in blocks-only mode, or this is a
// Reject tx INVs when the -blocksonly setting is enabled, or this is a
// block-relay-only peer
bool fBlocksOnly = m_ignore_incoming_txs || (pfrom.m_tx_relay == nullptr);
bool reject_tx_invs{m_ignore_incoming_txs || (pfrom.m_tx_relay == nullptr)};
// Allow peers with relay permission to send data other than blocks in blocks only mode
if (pfrom.HasPermission(NetPermissionFlags::Relay)) {
fBlocksOnly = false;
reject_tx_invs = false;
}
LOCK(cs_main);
@ -3005,7 +3005,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
pfrom.AddKnownTx(inv.hash);
if (fBlocksOnly) {
if (reject_tx_invs) {
LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.hash.ToString(), pfrom.GetId());
pfrom.fDisconnect = true;
return;