From 9190b01d8dcf03b74e9b9e1653688a97ac171b37 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Wed, 31 Mar 2021 18:34:49 +0100 Subject: [PATCH] [net processing] Add Orphanage empty consistency check When removing the final peer, assert that m_tx_orphanage is empty. --- src/net_processing.cpp | 1 + src/txorphanage.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 9c4544df21..c2202c73da 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1194,6 +1194,7 @@ void PeerManagerImpl::FinalizeNode(const CNode& node) assert(m_outbound_peers_with_protect_from_disconnect == 0); assert(m_wtxid_relay_peers == 0); assert(m_txrequest.Size() == 0); + assert(m_orphanage.Size() == 0); } } // cs_main if (node.fSuccessfullyConnected && misbehavior == 0 && diff --git a/src/txorphanage.h b/src/txorphanage.h index e4266e470a..24c8318f36 100644 --- a/src/txorphanage.h +++ b/src/txorphanage.h @@ -47,6 +47,13 @@ public: * (ie orphans that may have found their final missing parent, and so should be reconsidered for the mempool) */ void AddChildrenToWorkSet(const CTransaction& tx, std::set& orphan_work_set) const EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans); + /** Return how many entries exist in the orphange */ + size_t Size() LOCKS_EXCLUDED(::g_cs_orphans) + { + LOCK(::g_cs_orphans); + return m_orphans.size(); + } + protected: struct OrphanTx { CTransactionRef tx;