Skip to content

Commit 5c786a0

Browse files
committed
[refactor] use Wtxid for m_wtxids_fee_calculations
1 parent 21d9857 commit 5c786a0

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/test/txpackage_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
668668
const CFeeRate expected_feerate(1 * COIN, GetVirtualTransactionSize(*ptx_parent3) + GetVirtualTransactionSize(*ptx_mixed_child));
669669
BOOST_CHECK(it_parent3->second.m_effective_feerate.value() == expected_feerate);
670670
BOOST_CHECK(it_child->second.m_effective_feerate.value() == expected_feerate);
671-
std::vector<uint256> expected_wtxids({ptx_parent3->GetWitnessHash(), ptx_mixed_child->GetWitnessHash()});
671+
std::vector<Wtxid> expected_wtxids({ptx_parent3->GetWitnessHash(), ptx_mixed_child->GetWitnessHash()});
672672
BOOST_CHECK(it_parent3->second.m_wtxids_fee_calculations.value() == expected_wtxids);
673673
BOOST_CHECK(it_child->second.m_wtxids_fee_calculations.value() == expected_wtxids);
674674
}
@@ -756,7 +756,7 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
756756
GetVirtualTransactionSize(*tx_parent) + GetVirtualTransactionSize(*tx_child));
757757
BOOST_CHECK(it_parent->second.m_effective_feerate.value() == expected_feerate);
758758
BOOST_CHECK(it_child->second.m_effective_feerate.value() == expected_feerate);
759-
std::vector<uint256> expected_wtxids({tx_parent->GetWitnessHash(), tx_child->GetWitnessHash()});
759+
std::vector<Wtxid> expected_wtxids({tx_parent->GetWitnessHash(), tx_child->GetWitnessHash()});
760760
BOOST_CHECK(it_parent->second.m_wtxids_fee_calculations.value() == expected_wtxids);
761761
BOOST_CHECK(it_child->second.m_wtxids_fee_calculations.value() == expected_wtxids);
762762
BOOST_CHECK(expected_feerate.GetFeePerK() > 1000);
@@ -820,7 +820,7 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
820820
BOOST_CHECK(it_child->second.m_result_type == MempoolAcceptResult::ResultType::VALID);
821821
BOOST_CHECK(it_child->second.m_base_fees.value() == child_fee);
822822
BOOST_CHECK(it_child->second.m_effective_feerate.value() == expected_feerate);
823-
std::vector<uint256> expected_wtxids({tx_parent_cheap->GetWitnessHash(), tx_child_cheap->GetWitnessHash()});
823+
std::vector<Wtxid> expected_wtxids({tx_parent_cheap->GetWitnessHash(), tx_child_cheap->GetWitnessHash()});
824824
BOOST_CHECK(it_parent->second.m_wtxids_fee_calculations.value() == expected_wtxids);
825825
BOOST_CHECK(it_child->second.m_wtxids_fee_calculations.value() == expected_wtxids);
826826
}

src/validation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>&
12011201
}
12021202
}
12031203

1204-
std::vector<uint256> all_package_wtxids;
1204+
std::vector<Wtxid> all_package_wtxids;
12051205
all_package_wtxids.reserve(workspaces.size());
12061206
std::transform(workspaces.cbegin(), workspaces.cend(), std::back_inserter(all_package_wtxids),
12071207
[](const auto& ws) { return ws.m_ptx->GetWitnessHash(); });
@@ -1211,7 +1211,7 @@ bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>&
12111211
const auto effective_feerate = args.m_package_feerates ? ws.m_package_feerate :
12121212
CFeeRate{ws.m_modified_fees, static_cast<uint32_t>(ws.m_vsize)};
12131213
const auto effective_feerate_wtxids = args.m_package_feerates ? all_package_wtxids :
1214-
std::vector<uint256>({ws.m_ptx->GetWitnessHash()});
1214+
std::vector<Wtxid>{ws.m_ptx->GetWitnessHash()};
12151215
results.emplace(ws.m_ptx->GetWitnessHash(),
12161216
MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize,
12171217
ws.m_base_fees, effective_feerate, effective_feerate_wtxids));
@@ -1226,6 +1226,7 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef
12261226
LOCK(m_pool.cs); // mempool "read lock" (held through GetMainSignals().TransactionAddedToMempool())
12271227

12281228
Workspace ws(ptx);
1229+
const std::vector<Wtxid> single_wtxid{ws.m_ptx->GetWitnessHash()};
12291230

12301231
if (!PreChecks(args, ws)) return MempoolAcceptResult::Failure(ws.m_state);
12311232

@@ -1238,7 +1239,6 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef
12381239
if (!ConsensusScriptChecks(args, ws)) return MempoolAcceptResult::Failure(ws.m_state);
12391240

12401241
const CFeeRate effective_feerate{ws.m_modified_fees, static_cast<uint32_t>(ws.m_vsize)};
1241-
const std::vector<uint256> single_wtxid{ws.m_ptx->GetWitnessHash()};
12421242
// Tx was accepted, but not added
12431243
if (args.m_test_accept) {
12441244
return MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize,
@@ -1314,7 +1314,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
13141314
return PackageMempoolAcceptResult(package_state, std::move(results));
13151315
}
13161316

1317-
std::vector<uint256> all_package_wtxids;
1317+
std::vector<Wtxid> all_package_wtxids;
13181318
all_package_wtxids.reserve(workspaces.size());
13191319
std::transform(workspaces.cbegin(), workspaces.cend(), std::back_inserter(all_package_wtxids),
13201320
[](const auto& ws) { return ws.m_ptx->GetWitnessHash(); });
@@ -1330,7 +1330,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
13301330
const auto effective_feerate = args.m_package_feerates ? ws.m_package_feerate :
13311331
CFeeRate{ws.m_modified_fees, static_cast<uint32_t>(ws.m_vsize)};
13321332
const auto effective_feerate_wtxids = args.m_package_feerates ? all_package_wtxids :
1333-
std::vector<uint256>{ws.m_ptx->GetWitnessHash()};
1333+
std::vector<Wtxid>{ws.m_ptx->GetWitnessHash()};
13341334
results.emplace(ws.m_ptx->GetWitnessHash(),
13351335
MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions),
13361336
ws.m_vsize, ws.m_base_fees, effective_feerate,

src/validation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct MempoolAcceptResult {
149149
* package. This is not necessarily equivalent to the list of transactions passed to
150150
* ProcessNewPackage().
151151
* Only present when m_result_type = ResultType::VALID. */
152-
const std::optional<std::vector<uint256>> m_wtxids_fee_calculations;
152+
const std::optional<std::vector<Wtxid>> m_wtxids_fee_calculations;
153153

154154
// The following field is only present when m_result_type = ResultType::DIFFERENT_WITNESS
155155
/** The wtxid of the transaction in the mempool which has the same txid but different witness. */
@@ -163,7 +163,7 @@ struct MempoolAcceptResult {
163163
int64_t vsize,
164164
CAmount fees,
165165
CFeeRate effective_feerate,
166-
const std::vector<uint256>& wtxids_fee_calculations) {
166+
const std::vector<Wtxid>& wtxids_fee_calculations) {
167167
return MempoolAcceptResult(std::move(replaced_txns), vsize, fees,
168168
effective_feerate, wtxids_fee_calculations);
169169
}
@@ -189,7 +189,7 @@ struct MempoolAcceptResult {
189189
int64_t vsize,
190190
CAmount fees,
191191
CFeeRate effective_feerate,
192-
const std::vector<uint256>& wtxids_fee_calculations)
192+
const std::vector<Wtxid>& wtxids_fee_calculations)
193193
: m_result_type(ResultType::VALID),
194194
m_replaced_transactions(std::move(replaced_txns)),
195195
m_vsize{vsize},

0 commit comments

Comments
 (0)