Merge bitcoin/bitcoin#24427: refactor: Release cs_main before MaybeSendFeefilter

faa329fd46 refactor: Release cs_main before MaybeSendFeefilter (MarcoFalke)

Pull request description:

  There is no need for any lock to be held, because net processing is single threaded. So holding the validation lock cs_main for sending a feefilter is confusing and might even degrade blockchain-related RPC performance minimally.

ACKs for top commit:
  ajtowns:
    ACK faa329fd46 ; code review only
  vasild:
    ACK faa329fd46

Tree-SHA512: 3e7f9faff1631cc64c86fc1a354ada67617ad1e7a046625cc741f4711854eb41ca8aad5a51ef0d94ff65947b68dba8345c9f786b20ee0a8b7a2e8741cfced21f
pull/24489/head
MarcoFalke 3 years ago
commit 384866e870
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -415,7 +415,7 @@ private:
void RelayAddress(NodeId originator, const CAddress& addr, bool fReachable);
/** Send `feefilter` message. */
void MaybeSendFeefilter(CNode& node, std::chrono::microseconds current_time) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
void MaybeSendFeefilter(CNode& node, std::chrono::microseconds current_time);
const CChainParams& m_chainparams;
CConnman& m_connman;
@ -4506,8 +4506,6 @@ void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::micros
void PeerManagerImpl::MaybeSendFeefilter(CNode& pto, std::chrono::microseconds current_time)
{
AssertLockHeld(cs_main);
if (m_ignore_incoming_txs) return;
if (!pto.m_tx_relay) return;
if (pto.GetCommonVersion() < FEEFILTER_VERSION) return;
@ -5054,8 +5052,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
if (!vGetData.empty())
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::GETDATA, vGetData));
MaybeSendFeefilter(*pto, current_time);
} // release cs_main
MaybeSendFeefilter(*pto, current_time);
return true;
}

Loading…
Cancel
Save