mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
net_processing: move CNode data access out of lock
CNode::m_relays_tx and CNode::m_bloom_filter_loaded access don't require the Peer::TxRelay::m_bloom_filter_mutex lock, so move them out of the lock scope. See https://github.com/bitcoin/bitcoin/pull/21160#discussion_r736785417 and https://github.com/bitcoin/bitcoin/pull/21160#discussion_r736785662.
This commit is contained in:
parent
3297f5c11c
commit
21154ff927
1 changed files with 15 additions and 8 deletions
|
@ -2715,8 +2715,10 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||
pfrom.m_limited_node = (!(nServices & NODE_NETWORK) && (nServices & NODE_NETWORK_LIMITED));
|
||||
|
||||
if (peer->m_tx_relay != nullptr) {
|
||||
LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
|
||||
peer->m_tx_relay->m_relay_txs = fRelay; // set to true after we get the first filter* message
|
||||
{
|
||||
LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
|
||||
peer->m_tx_relay->m_relay_txs = fRelay; // set to true after we get the first filter* message
|
||||
}
|
||||
if (fRelay) pfrom.m_relays_txs = true;
|
||||
}
|
||||
|
||||
|
@ -4030,10 +4032,12 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||
}
|
||||
else if (peer->m_tx_relay != nullptr)
|
||||
{
|
||||
LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
|
||||
peer->m_tx_relay->m_bloom_filter.reset(new CBloomFilter(filter));
|
||||
{
|
||||
LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
|
||||
peer->m_tx_relay->m_bloom_filter.reset(new CBloomFilter(filter));
|
||||
peer->m_tx_relay->m_relay_txs = true;
|
||||
}
|
||||
pfrom.m_bloom_filter_loaded = true;
|
||||
peer->m_tx_relay->m_relay_txs = true;
|
||||
pfrom.m_relays_txs = true;
|
||||
}
|
||||
return;
|
||||
|
@ -4076,10 +4080,13 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||
if (peer->m_tx_relay == nullptr) {
|
||||
return;
|
||||
}
|
||||
LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
|
||||
peer->m_tx_relay->m_bloom_filter = nullptr;
|
||||
|
||||
{
|
||||
LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
|
||||
peer->m_tx_relay->m_bloom_filter = nullptr;
|
||||
peer->m_tx_relay->m_relay_txs = true;
|
||||
}
|
||||
pfrom.m_bloom_filter_loaded = false;
|
||||
peer->m_tx_relay->m_relay_txs = true;
|
||||
pfrom.m_relays_txs = true;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue