Skip to content

Commit

Permalink
ProcessOrphanTx: Move AddToCompactExtraTransactions call into Process…
Browse files Browse the repository at this point in the history
…OrphanTx
  • Loading branch information
jnewbery committed Jul 23, 2020
1 parent 50ca16a commit eb30f87
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,10 +2012,8 @@ static void ProcessHeadersMessage(CNode& pfrom, CConnman& connman, ChainstateMan
* 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 static ProcessOrphanTx(CConnman& connman, CTxMemPool& mempool, std::set<uint256>& orphan_work_set, std::list<CTransactionRef>& removed_txn) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans)
void static ProcessOrphanTx(CConnman& connman, CTxMemPool& mempool, std::set<uint256>& orphan_work_set) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans)
{
AssertLockHeld(cs_main);
AssertLockHeld(g_cs_orphans);
Expand All @@ -2030,6 +2028,7 @@ void static ProcessOrphanTx(CConnman& connman, CTxMemPool& mempool, std::set<uin

const CTransactionRef porphanTx = orphan_it->second.tx;
TxValidationState state;
std::list<CTransactionRef> removed_txn;

if (AcceptToMemoryPool(mempool, state, porphanTx, &removed_txn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
Expand All @@ -2043,6 +2042,9 @@ void static ProcessOrphanTx(CConnman& connman, CTxMemPool& mempool, std::set<uin
}
}
EraseOrphanTx(orphanHash);
for (const CTransactionRef& removedTx : removed_txn) {
AddToCompactExtraTransactions(removedTx);
}
} else if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) {
if (state.IsInvalid()) {
LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s from peer=%d. %s\n",
Expand Down Expand Up @@ -2987,7 +2989,7 @@ void ProcessMessage(
mempool.size(), mempool.DynamicMemoryUsage() / 1000);

// Recursively process any orphan transactions that depended on this one
ProcessOrphanTx(connman, mempool, pfrom.orphan_work_set, lRemovedTxn);
ProcessOrphanTx(connman, mempool, pfrom.orphan_work_set);
}
else if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS)
{
Expand Down Expand Up @@ -3775,10 +3777,7 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
if (!pfrom->orphan_work_set.empty()) {
std::list<CTransactionRef> removed_txn;
LOCK2(cs_main, g_cs_orphans);
ProcessOrphanTx(*connman, m_mempool, pfrom->orphan_work_set, removed_txn);
for (const CTransactionRef& removedTx : removed_txn) {
AddToCompactExtraTransactions(removedTx);
}
ProcessOrphanTx(*connman, m_mempool, pfrom->orphan_work_set);
}

if (pfrom->fDisconnect)
Expand Down

0 comments on commit eb30f87

Please sign in to comment.