diff options
author | John Newbery <john@johnnewbery.com> | 2020-06-25 17:26:55 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2020-09-07 20:12:02 +0100 |
commit | 001343f4bc8b22fa9e313bd2867756eb9d614fa3 (patch) | |
tree | 15afc4131cf0b4bb160c2c9e080c643919f8f7a2 /src/net_processing.cpp | |
parent | 4fce726bd1e35a686cd9d48add5da22b1b5e25e1 (diff) |
ProcessOrphanTx: Move AddToCompactExtraTransactions call into ProcessOrphanTx
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r-- | src/net_processing.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 5c3b71faa2..c82574c4f6 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2041,10 +2041,8 @@ void PeerManager::ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHe * 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 * reconsidered. - * @param[out] removed_txn Transactions that were removed from the mempool as a result of an - * orphan transaction being added. */ -void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<CTransactionRef>& removed_txn) +void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set) { AssertLockHeld(cs_main); AssertLockHeld(g_cs_orphans); @@ -2058,6 +2056,7 @@ void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list< const CTransactionRef porphanTx = orphan_it->second.tx; TxValidationState state; + std::list<CTransactionRef> removed_txn; if (AcceptToMemoryPool(m_mempool, state, porphanTx, &removed_txn, false /* bypass_limits */, 0 /* nAbsurdFee */)) { LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString()); @@ -2071,6 +2070,9 @@ void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list< } } EraseOrphanTx(orphanHash); + for (const CTransactionRef& removedTx : removed_txn) { + AddToCompactExtraTransactions(removedTx); + } break; } else if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) { if (state.IsInvalid()) { @@ -3034,8 +3036,12 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat tx.GetHash().ToString(), m_mempool.size(), m_mempool.DynamicMemoryUsage() / 1000); + for (const CTransactionRef& removedTx : lRemovedTxn) { + AddToCompactExtraTransactions(removedTx); + } + // Recursively process any orphan transactions that depended on this one - ProcessOrphanTx(pfrom.orphan_work_set, lRemovedTxn); + ProcessOrphanTx(pfrom.orphan_work_set); } else if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) { @@ -3138,9 +3144,6 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat } } - for (const CTransactionRef& removedTx : lRemovedTxn) - AddToCompactExtraTransactions(removedTx); - // If a tx has been detected by recentRejects, we will have reached // this point and the tx will have been ignored. Because we haven't run // the tx through AcceptToMemoryPool, we won't have computed a DoS @@ -3853,12 +3856,8 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP ProcessGetData(*pfrom, m_chainparams, m_connman, m_mempool, interruptMsgProc); if (!pfrom->orphan_work_set.empty()) { - std::list<CTransactionRef> removed_txn; LOCK2(cs_main, g_cs_orphans); - ProcessOrphanTx(pfrom->orphan_work_set, removed_txn); - for (const CTransactionRef& removedTx : removed_txn) { - AddToCompactExtraTransactions(removedTx); - } + ProcessOrphanTx(pfrom->orphan_work_set); } if (pfrom->fDisconnect) |