Skip to content

Commit 9190b01

Browse files
committed
[net processing] Add Orphanage empty consistency check
When removing the final peer, assert that m_tx_orphanage is empty.
1 parent 201c5e4 commit 9190b01

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,7 @@ void PeerManagerImpl::FinalizeNode(const CNode& node)
11941194
assert(m_outbound_peers_with_protect_from_disconnect == 0);
11951195
assert(m_wtxid_relay_peers == 0);
11961196
assert(m_txrequest.Size() == 0);
1197+
assert(m_orphanage.Size() == 0);
11971198
}
11981199
} // cs_main
11991200
if (node.fSuccessfullyConnected && misbehavior == 0 &&

src/txorphanage.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class TxOrphanage {
4747
* (ie orphans that may have found their final missing parent, and so should be reconsidered for the mempool) */
4848
void AddChildrenToWorkSet(const CTransaction& tx, std::set<uint256>& orphan_work_set) const EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
4949

50+
/** Return how many entries exist in the orphange */
51+
size_t Size() LOCKS_EXCLUDED(::g_cs_orphans)
52+
{
53+
LOCK(::g_cs_orphans);
54+
return m_orphans.size();
55+
}
56+
5057
protected:
5158
struct OrphanTx {
5259
CTransactionRef tx;

0 commit comments

Comments
 (0)