Skip to content

Commit e637dc2

Browse files
committed
refactor: Replace uint256 type with Wtxid in PackageMempoolAcceptResult struct
1 parent a3baead commit e637dc2

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/validation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ class MemPoolAccept
696696
// cache - should only be called after successful validation of all transactions in the package.
697697
// Does not call LimitMempoolSize(), so mempool max_size_bytes may be temporarily exceeded.
698698
bool SubmitPackage(const ATMPArgs& args, std::vector<Workspace>& workspaces, PackageValidationState& package_state,
699-
std::map<uint256, MempoolAcceptResult>& results)
699+
std::map<Wtxid, MempoolAcceptResult>& results)
700700
EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs);
701701

702702
// Compare a package's feerate against minimum allowed.
@@ -1338,7 +1338,7 @@ void MemPoolAccept::FinalizeSubpackage(const ATMPArgs& args)
13381338

13391339
bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>& workspaces,
13401340
PackageValidationState& package_state,
1341-
std::map<uint256, MempoolAcceptResult>& results)
1341+
std::map<Wtxid, MempoolAcceptResult>& results)
13421342
{
13431343
AssertLockHeld(cs_main);
13441344
AssertLockHeld(m_pool.cs);
@@ -1512,7 +1512,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
15121512
workspaces.reserve(txns.size());
15131513
std::transform(txns.cbegin(), txns.cend(), std::back_inserter(workspaces),
15141514
[](const auto& tx) { return Workspace(tx); });
1515-
std::map<uint256, MempoolAcceptResult> results;
1515+
std::map<Wtxid, MempoolAcceptResult> results;
15161516

15171517
LOCK(m_pool.cs);
15181518

@@ -1751,11 +1751,11 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package,
17511751
LOCK(m_pool.cs);
17521752
// Stores results from which we will create the returned PackageMempoolAcceptResult.
17531753
// A result may be changed if a mempool transaction is evicted later due to LimitMempoolSize().
1754-
std::map<uint256, MempoolAcceptResult> results_final;
1754+
std::map<Wtxid, MempoolAcceptResult> results_final;
17551755
// Results from individual validation which will be returned if no other result is available for
17561756
// this transaction. "Nonfinal" because if a transaction fails by itself but succeeds later
17571757
// (i.e. when evaluated with a fee-bumping child), the result in this map may be discarded.
1758-
std::map<uint256, MempoolAcceptResult> individual_results_nonfinal;
1758+
std::map<Wtxid, MempoolAcceptResult> individual_results_nonfinal;
17591759
// Tracks whether we think package submission could result in successful entry to the mempool
17601760
bool quit_early{false};
17611761
std::vector<CTransactionRef> txns_package_eval;

src/validation.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ struct MempoolAcceptResult {
154154
const std::optional<std::vector<Wtxid>> m_wtxids_fee_calculations;
155155

156156
/** The wtxid of the transaction in the mempool which has the same txid but different witness. */
157-
const std::optional<uint256> m_other_wtxid;
157+
const std::optional<Wtxid> m_other_wtxid;
158158

159159
static MempoolAcceptResult Failure(TxValidationState state) {
160160
return MempoolAcceptResult(state);
@@ -179,7 +179,7 @@ struct MempoolAcceptResult {
179179
return MempoolAcceptResult(vsize, fees);
180180
}
181181

182-
static MempoolAcceptResult MempoolTxDifferentWitness(const uint256& other_wtxid) {
182+
static MempoolAcceptResult MempoolTxDifferentWitness(const Wtxid& other_wtxid) {
183183
return MempoolAcceptResult(other_wtxid);
184184
}
185185

@@ -218,7 +218,7 @@ struct MempoolAcceptResult {
218218
: m_result_type(ResultType::MEMPOOL_ENTRY), m_vsize{vsize}, m_base_fees(fees) {}
219219

220220
/** Constructor for witness-swapped case. */
221-
explicit MempoolAcceptResult(const uint256& other_wtxid)
221+
explicit MempoolAcceptResult(const Wtxid& other_wtxid)
222222
: m_result_type(ResultType::DIFFERENT_WITNESS), m_other_wtxid(other_wtxid) {}
223223
};
224224

@@ -234,18 +234,18 @@ struct PackageMempoolAcceptResult
234234
* present, it means validation was unfinished for that transaction. If there
235235
* was a package-wide error (see result in m_state), m_tx_results will be empty.
236236
*/
237-
std::map<uint256, MempoolAcceptResult> m_tx_results;
237+
std::map<Wtxid, MempoolAcceptResult> m_tx_results;
238238

239239
explicit PackageMempoolAcceptResult(PackageValidationState state,
240-
std::map<uint256, MempoolAcceptResult>&& results)
240+
std::map<Wtxid, MempoolAcceptResult>&& results)
241241
: m_state{state}, m_tx_results(std::move(results)) {}
242242

243243
explicit PackageMempoolAcceptResult(PackageValidationState state, CFeeRate feerate,
244-
std::map<uint256, MempoolAcceptResult>&& results)
244+
std::map<Wtxid, MempoolAcceptResult>&& results)
245245
: m_state{state}, m_tx_results(std::move(results)) {}
246246

247247
/** Constructor to create a PackageMempoolAcceptResult from a single MempoolAcceptResult */
248-
explicit PackageMempoolAcceptResult(const uint256& wtxid, const MempoolAcceptResult& result)
248+
explicit PackageMempoolAcceptResult(const Wtxid& wtxid, const MempoolAcceptResult& result)
249249
: m_tx_results{ {wtxid, result} } {}
250250
};
251251

0 commit comments

Comments
 (0)