diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 4537754231..803f3d51aa 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1930,12 +1930,14 @@ void PeerManagerImpl::StartScheduledTasks(CScheduler& scheduler) */ void PeerManagerImpl::BlockConnected(const std::shared_ptr& pblock, const CBlockIndex* pindex) { - LOCK2(::cs_main, g_cs_orphans); + { + LOCK2(::cs_main, g_cs_orphans); - auto orphanWorkSet = m_orphanage.GetCandidatesForBlock(*pblock); - while (!orphanWorkSet.empty()) { - LogPrint(BCLog::MEMPOOL, "Trying to process %d orphans\n", orphanWorkSet.size()); - ProcessOrphanTx(orphanWorkSet); + auto orphanWorkSet = m_orphanage.GetCandidatesForBlock(*pblock); + while (!orphanWorkSet.empty()) { + LogPrint(BCLog::MEMPOOL, "Trying to process %d orphans\n", orphanWorkSet.size()); + ProcessOrphanTx(orphanWorkSet); + } } m_orphanage.EraseForBlock(*pblock); diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp index 84835e0aad..ce9d6435ce 100644 --- a/src/txorphanage.cpp +++ b/src/txorphanage.cpp @@ -197,7 +197,7 @@ std::set TxOrphanage::GetCandidatesForBlock(const CBlock& block) void TxOrphanage::EraseForBlock(const CBlock& block) { - AssertLockHeld(g_cs_orphans); + LOCK(g_cs_orphans); std::vector vOrphanErase;