@@ -114,7 +114,27 @@ double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pin
114
114
void PruneBlockFilesManual (Chainstate& active_chainstate, int nManualPruneHeight);
115
115
116
116
/* *
117
- * Validation result for a single transaction mempool acceptance.
117
+ * Validation result for a transaction evaluated by MemPoolAccept (single or package).
118
+ * Here are the expected fields and properties of a result depending on its ResultType, applicable to
119
+ * results returned from package evaluation:
120
+ *+---------------------------+----------------+-------------------+------------------+----------------+-------------------+
121
+ *| Field or property | VALID | INVALID | MEMPOOL_ENTRY | DIFFERENT_WITNESS |
122
+ *| | |--------------------------------------| | |
123
+ *| | | TX_RECONSIDERABLE | Other | | |
124
+ *+---------------------------+----------------+-------------------+------------------+----------------+-------------------+
125
+ *| txid in mempool? | yes | no | no* | yes | yes |
126
+ *| wtxid in mempool? | yes | no | no* | yes | no |
127
+ *| m_state | yes, IsValid() | yes, IsInvalid() | yes, IsInvalid() | yes, IsValid() | yes, IsValid() |
128
+ *| m_replaced_transactions | yes | no | no | no | no |
129
+ *| m_vsize | yes | no | no | yes | no |
130
+ *| m_base_fees | yes | no | no | yes | no |
131
+ *| m_effective_feerate | yes | yes | no | no | no |
132
+ *| m_wtxids_fee_calculations | yes | yes | no | no | no |
133
+ *| m_other_wtxid | no | no | no | no | yes |
134
+ *+---------------------------+----------------+-------------------+------------------+----------------+-------------------+
135
+ * (*) Individual transaction acceptance doesn't return MEMPOOL_ENTRY and DIFFERENT_WITNESS. It returns
136
+ * INVALID, with the errors txn-already-in-mempool and txn-same-nonwitness-data-in-mempool
137
+ * respectively. In those cases, the txid or wtxid may be in the mempool for a TX_CONFLICT.
118
138
*/
119
139
struct MempoolAcceptResult {
120
140
/* * Used to indicate the results of mempool validation. */
@@ -130,7 +150,6 @@ struct MempoolAcceptResult {
130
150
/* * Contains information about why the transaction failed. */
131
151
const TxValidationState m_state;
132
152
133
- // The following fields are only present when m_result_type = ResultType::VALID or MEMPOOL_ENTRY
134
153
/* * Mempool transactions replaced by the tx. */
135
154
const std::optional<std::list<CTransactionRef>> m_replaced_transactions;
136
155
/* * Virtual size as used by the mempool, calculated using serialized size and sigops. */
@@ -141,7 +160,6 @@ struct MempoolAcceptResult {
141
160
* using prioritisetransaction (i.e. modified fees). If this transaction was submitted as a
142
161
* package, this is the package feerate, which may also include its descendants and/or
143
162
* ancestors (see m_wtxids_fee_calculations below).
144
- * Only present when m_result_type = ResultType::VALID.
145
163
*/
146
164
const std::optional<CFeeRate> m_effective_feerate;
147
165
/* * Contains the wtxids of the transactions used for fee-related checks. Includes this
@@ -151,14 +169,19 @@ struct MempoolAcceptResult {
151
169
* Only present when m_result_type = ResultType::VALID. */
152
170
const std::optional<std::vector<Wtxid>> m_wtxids_fee_calculations;
153
171
154
- // The following field is only present when m_result_type = ResultType::DIFFERENT_WITNESS
155
172
/* * The wtxid of the transaction in the mempool which has the same txid but different witness. */
156
173
const std::optional<uint256> m_other_wtxid;
157
174
158
175
static MempoolAcceptResult Failure (TxValidationState state) {
159
176
return MempoolAcceptResult (state);
160
177
}
161
178
179
+ static MempoolAcceptResult FeeFailure (TxValidationState state,
180
+ CFeeRate effective_feerate,
181
+ const std::vector<Wtxid>& wtxids_fee_calculations) {
182
+ return MempoolAcceptResult (state, effective_feerate, wtxids_fee_calculations);
183
+ }
184
+
162
185
static MempoolAcceptResult Success (std::list<CTransactionRef>&& replaced_txns,
163
186
int64_t vsize,
164
187
CAmount fees,
@@ -197,6 +220,15 @@ struct MempoolAcceptResult {
197
220
m_effective_feerate (effective_feerate),
198
221
m_wtxids_fee_calculations (wtxids_fee_calculations) {}
199
222
223
+ /* * Constructor for fee-related failure case */
224
+ explicit MempoolAcceptResult (TxValidationState state,
225
+ CFeeRate effective_feerate,
226
+ const std::vector<Wtxid>& wtxids_fee_calculations)
227
+ : m_result_type(ResultType::INVALID),
228
+ m_state(state),
229
+ m_effective_feerate(effective_feerate),
230
+ m_wtxids_fee_calculations(wtxids_fee_calculations) {}
231
+
200
232
/* * Constructor for already-in-mempool case. It wouldn't replace any transactions. */
201
233
explicit MempoolAcceptResult (int64_t vsize, CAmount fees)
202
234
: m_result_type(ResultType::MEMPOOL_ENTRY), m_vsize{vsize}, m_base_fees(fees) {}
0 commit comments