HomePhabricator

[refactor] consolidate valid MempoolAcceptResult processing

Description

[refactor] consolidate valid MempoolAcceptResult processing

Summary:
Deduplicate code that exists in both tx processing and ProcessOrphanTx.
Additionally, this can be reused in a function that handles multiple
MempoolAcceptResults from package submission.

refactor: consolidate MempoolAcceptResult processing

Every time we try to ProcessTransaction (i.e. submit a tx to mempool), we use the result to update a few net processing data structures. For example, after a failure, the {wtxid, txid, both, neither} (depending on reason) should be cached in m_recent_rejects so we don't try to download/validate it again.

There are 2 current places and at least 1 future place where we need to process MempoolAcceptResult
[...]

Consolidate this code so it isn't repeated in 2 places and so we can reuse it in a future PR.

Backport of core#29619.

Refactor only, there is no change in behavior.

Backport note: the TX_UNKNOWN validation state has not been backported and is skipped in the net_processing check for invalid txs. To this date this enum value is never used upstream so we're not missing anything (introduced in core#28785).

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D16346

Details

Provenance
FabienAuthored on Jun 18 2024, 14:33
FabienPushed on Jun 18 2024, 17:45
Reviewer
Restricted Project
Differential Revision
D16346: [refactor] consolidate valid MempoolAcceptResult processing
Parents
rABC6e6b74109f39: [Cashtab] Refactor script generating functions to use ecash-lib Script
Branches
Unknown
Tags
Unknown