mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
net_processing: Localise orphan_work_set handling to ProcessOrphanTx
This commit is contained in:
parent
0027174b39
commit
6f8e442ba6
1 changed files with 11 additions and 10 deletions
|
@ -596,8 +596,9 @@ private:
|
||||||
* orphan will be reconsidered on each call of this function. This set
|
* orphan will be reconsidered on each call of this function. This set
|
||||||
* may be added to if accepting an orphan causes its children to be
|
* may be added to if accepting an orphan causes its children to be
|
||||||
* reconsidered.
|
* reconsidered.
|
||||||
|
* @return True if there are still orphans in this peer's work set.
|
||||||
*/
|
*/
|
||||||
void ProcessOrphanTx(Peer& peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans)
|
bool ProcessOrphanTx(Peer& peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex);
|
||||||
/** Process a single headers message from a peer.
|
/** Process a single headers message from a peer.
|
||||||
*
|
*
|
||||||
|
@ -2883,12 +2884,14 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerManagerImpl::ProcessOrphanTx(Peer& peer)
|
bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
|
||||||
{
|
{
|
||||||
AssertLockHeld(g_msgproc_mutex);
|
AssertLockHeld(g_msgproc_mutex);
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
AssertLockHeld(g_cs_orphans);
|
AssertLockHeld(g_cs_orphans);
|
||||||
|
|
||||||
|
if (peer.m_orphan_work_set.empty()) return false;
|
||||||
|
|
||||||
while (!peer.m_orphan_work_set.empty()) {
|
while (!peer.m_orphan_work_set.empty()) {
|
||||||
const uint256 orphanHash = *peer.m_orphan_work_set.begin();
|
const uint256 orphanHash = *peer.m_orphan_work_set.begin();
|
||||||
peer.m_orphan_work_set.erase(peer.m_orphan_work_set.begin());
|
peer.m_orphan_work_set.erase(peer.m_orphan_work_set.begin());
|
||||||
|
@ -2953,6 +2956,8 @@ void PeerManagerImpl::ProcessOrphanTx(Peer& peer)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return !peer.m_orphan_work_set.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& node, Peer& peer,
|
bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& node, Peer& peer,
|
||||||
|
@ -4768,16 +4773,17 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool has_more_orphans;
|
||||||
{
|
{
|
||||||
LOCK2(cs_main, g_cs_orphans);
|
LOCK2(cs_main, g_cs_orphans);
|
||||||
if (!peer->m_orphan_work_set.empty()) {
|
has_more_orphans = ProcessOrphanTx(*peer);
|
||||||
ProcessOrphanTx(*peer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pfrom->fDisconnect)
|
if (pfrom->fDisconnect)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (has_more_orphans) return true;
|
||||||
|
|
||||||
// this maintains the order of responses
|
// this maintains the order of responses
|
||||||
// and prevents m_getdata_requests to grow unbounded
|
// and prevents m_getdata_requests to grow unbounded
|
||||||
{
|
{
|
||||||
|
@ -4785,11 +4791,6 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
|
||||||
if (!peer->m_getdata_requests.empty()) return true;
|
if (!peer->m_getdata_requests.empty()) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
LOCK(g_cs_orphans);
|
|
||||||
if (!peer->m_orphan_work_set.empty()) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't bother if send buffer is too full to respond anyway
|
// Don't bother if send buffer is too full to respond anyway
|
||||||
if (pfrom->fPauseSend) return false;
|
if (pfrom->fPauseSend) return false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue