Skip to content

Commit 2888653

Browse files
committed
[refactor] rename maybe_add_extra_compact_tx to first_time_failure
The usage of this bool will increase in scope in the next commit. For this commit, the value of this bool is accurate at each ProcessInvalidTx callsite: - ProcessOrphanTx -> this tx is an orphan i.e. has been rejected before - ProcessPackageResult -> 1p1c only, each transaction is either an orphan or in m_lazy_recent_rejects_reconsiderable - ProcessMessage -> tx was received over p2p and validated for the first time
1 parent f48d36c commit 2888653

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/net_processing.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,12 @@ class PeerManagerImpl final : public PeerManager
581581
bool MaybeDiscourageAndDisconnect(CNode& pnode, Peer& peer);
582582

583583
/** Handle a transaction whose result was not MempoolAcceptResult::ResultType::VALID.
584-
* @param[in] maybe_add_extra_compact_tx Whether this tx should be added to vExtraTxnForCompact.
584+
* @param[in] first_time_failure Whether this tx should be added to vExtraTxnForCompact.
585585
* Set to false if the tx has already been rejected before,
586586
* e.g. is an orphan, to avoid adding duplicate entries.
587587
* Updates m_txrequest, m_lazy_recent_rejects, m_lazy_recent_rejects_reconsiderable, m_orphanage, and vExtraTxnForCompact. */
588588
void ProcessInvalidTx(NodeId nodeid, const CTransactionRef& tx, const TxValidationState& result,
589-
bool maybe_add_extra_compact_tx)
589+
bool first_time_failure)
590590
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex, m_tx_download_mutex);
591591

592592
/** Handle a transaction whose result was MempoolAcceptResult::ResultType::VALID.
@@ -3052,7 +3052,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
30523052
}
30533053

30543054
void PeerManagerImpl::ProcessInvalidTx(NodeId nodeid, const CTransactionRef& ptx, const TxValidationState& state,
3055-
bool maybe_add_extra_compact_tx)
3055+
bool first_time_failure)
30563056
{
30573057
AssertLockNotHeld(m_peer_mutex);
30583058
AssertLockHeld(g_msgproc_mutex);
@@ -3106,7 +3106,7 @@ void PeerManagerImpl::ProcessInvalidTx(NodeId nodeid, const CTransactionRef& ptx
31063106
RecentRejectsFilter().insert(ptx->GetHash().ToUint256());
31073107
m_txrequest.ForgetTxHash(ptx->GetHash());
31083108
}
3109-
if (maybe_add_extra_compact_tx && RecursiveDynamicUsage(*ptx) < 100000) {
3109+
if (first_time_failure && RecursiveDynamicUsage(*ptx) < 100000) {
31103110
AddToCompactExtraTransactions(ptx);
31113111
}
31123112
}
@@ -3191,7 +3191,7 @@ void PeerManagerImpl::ProcessPackageResult(const PackageToValidate& package_to_v
31913191
// added there when added to the orphanage or rejected for TX_RECONSIDERABLE.
31923192
// This should be updated if package submission is ever used for transactions
31933193
// that haven't already been validated before.
3194-
ProcessInvalidTx(nodeid, tx, tx_result.m_state, /*maybe_add_extra_compact_tx=*/false);
3194+
ProcessInvalidTx(nodeid, tx, tx_result.m_state, /*first_time_failure=*/false);
31953195
break;
31963196
}
31973197
case MempoolAcceptResult::ResultType::MEMPOOL_ENTRY:
@@ -3290,7 +3290,7 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
32903290
state.GetResult() != TxValidationResult::TX_UNKNOWN &&
32913291
state.GetResult() != TxValidationResult::TX_NO_MEMPOOL &&
32923292
state.GetResult() != TxValidationResult::TX_RESULT_UNSET)) {
3293-
ProcessInvalidTx(peer.m_id, porphanTx, state, /*maybe_add_extra_compact_tx=*/false);
3293+
ProcessInvalidTx(peer.m_id, porphanTx, state, /*first_time_failure=*/false);
32943294
}
32953295
return true;
32963296
}
@@ -4574,7 +4574,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
45744574
}
45754575
}
45764576
if (state.IsInvalid()) {
4577-
ProcessInvalidTx(pfrom.GetId(), ptx, state, /*maybe_add_extra_compact_tx=*/true);
4577+
ProcessInvalidTx(pfrom.GetId(), ptx, state, /*first_time_failure=*/true);
45784578
}
45794579
// When a transaction fails for TX_RECONSIDERABLE, look for a matching child in the
45804580
// orphanage, as it is possible that they succeed as a package.

0 commit comments

Comments
 (0)