mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-10 17:02:03 +02:00
[refactor] use Wtxid for m_wtxids_fee_calculations
This commit is contained in:
parent
21d985784f
commit
5c786a026a
@ -668,7 +668,7 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
|
||||
const CFeeRate expected_feerate(1 * COIN, GetVirtualTransactionSize(*ptx_parent3) + GetVirtualTransactionSize(*ptx_mixed_child));
|
||||
BOOST_CHECK(it_parent3->second.m_effective_feerate.value() == expected_feerate);
|
||||
BOOST_CHECK(it_child->second.m_effective_feerate.value() == expected_feerate);
|
||||
std::vector<uint256> expected_wtxids({ptx_parent3->GetWitnessHash(), ptx_mixed_child->GetWitnessHash()});
|
||||
std::vector<Wtxid> expected_wtxids({ptx_parent3->GetWitnessHash(), ptx_mixed_child->GetWitnessHash()});
|
||||
BOOST_CHECK(it_parent3->second.m_wtxids_fee_calculations.value() == expected_wtxids);
|
||||
BOOST_CHECK(it_child->second.m_wtxids_fee_calculations.value() == expected_wtxids);
|
||||
}
|
||||
@ -756,7 +756,7 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
|
||||
GetVirtualTransactionSize(*tx_parent) + GetVirtualTransactionSize(*tx_child));
|
||||
BOOST_CHECK(it_parent->second.m_effective_feerate.value() == expected_feerate);
|
||||
BOOST_CHECK(it_child->second.m_effective_feerate.value() == expected_feerate);
|
||||
std::vector<uint256> expected_wtxids({tx_parent->GetWitnessHash(), tx_child->GetWitnessHash()});
|
||||
std::vector<Wtxid> expected_wtxids({tx_parent->GetWitnessHash(), tx_child->GetWitnessHash()});
|
||||
BOOST_CHECK(it_parent->second.m_wtxids_fee_calculations.value() == expected_wtxids);
|
||||
BOOST_CHECK(it_child->second.m_wtxids_fee_calculations.value() == expected_wtxids);
|
||||
BOOST_CHECK(expected_feerate.GetFeePerK() > 1000);
|
||||
@ -820,7 +820,7 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
|
||||
BOOST_CHECK(it_child->second.m_result_type == MempoolAcceptResult::ResultType::VALID);
|
||||
BOOST_CHECK(it_child->second.m_base_fees.value() == child_fee);
|
||||
BOOST_CHECK(it_child->second.m_effective_feerate.value() == expected_feerate);
|
||||
std::vector<uint256> expected_wtxids({tx_parent_cheap->GetWitnessHash(), tx_child_cheap->GetWitnessHash()});
|
||||
std::vector<Wtxid> expected_wtxids({tx_parent_cheap->GetWitnessHash(), tx_child_cheap->GetWitnessHash()});
|
||||
BOOST_CHECK(it_parent->second.m_wtxids_fee_calculations.value() == expected_wtxids);
|
||||
BOOST_CHECK(it_child->second.m_wtxids_fee_calculations.value() == expected_wtxids);
|
||||
}
|
||||
|
@ -1201,7 +1201,7 @@ bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>&
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<uint256> all_package_wtxids;
|
||||
std::vector<Wtxid> all_package_wtxids;
|
||||
all_package_wtxids.reserve(workspaces.size());
|
||||
std::transform(workspaces.cbegin(), workspaces.cend(), std::back_inserter(all_package_wtxids),
|
||||
[](const auto& ws) { return ws.m_ptx->GetWitnessHash(); });
|
||||
@ -1211,7 +1211,7 @@ bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>&
|
||||
const auto effective_feerate = args.m_package_feerates ? ws.m_package_feerate :
|
||||
CFeeRate{ws.m_modified_fees, static_cast<uint32_t>(ws.m_vsize)};
|
||||
const auto effective_feerate_wtxids = args.m_package_feerates ? all_package_wtxids :
|
||||
std::vector<uint256>({ws.m_ptx->GetWitnessHash()});
|
||||
std::vector<Wtxid>{ws.m_ptx->GetWitnessHash()};
|
||||
results.emplace(ws.m_ptx->GetWitnessHash(),
|
||||
MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize,
|
||||
ws.m_base_fees, effective_feerate, effective_feerate_wtxids));
|
||||
@ -1226,6 +1226,7 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef
|
||||
LOCK(m_pool.cs); // mempool "read lock" (held through GetMainSignals().TransactionAddedToMempool())
|
||||
|
||||
Workspace ws(ptx);
|
||||
const std::vector<Wtxid> single_wtxid{ws.m_ptx->GetWitnessHash()};
|
||||
|
||||
if (!PreChecks(args, ws)) return MempoolAcceptResult::Failure(ws.m_state);
|
||||
|
||||
@ -1238,7 +1239,6 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef
|
||||
if (!ConsensusScriptChecks(args, ws)) return MempoolAcceptResult::Failure(ws.m_state);
|
||||
|
||||
const CFeeRate effective_feerate{ws.m_modified_fees, static_cast<uint32_t>(ws.m_vsize)};
|
||||
const std::vector<uint256> single_wtxid{ws.m_ptx->GetWitnessHash()};
|
||||
// Tx was accepted, but not added
|
||||
if (args.m_test_accept) {
|
||||
return MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize,
|
||||
@ -1314,7 +1314,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
|
||||
return PackageMempoolAcceptResult(package_state, std::move(results));
|
||||
}
|
||||
|
||||
std::vector<uint256> all_package_wtxids;
|
||||
std::vector<Wtxid> all_package_wtxids;
|
||||
all_package_wtxids.reserve(workspaces.size());
|
||||
std::transform(workspaces.cbegin(), workspaces.cend(), std::back_inserter(all_package_wtxids),
|
||||
[](const auto& ws) { return ws.m_ptx->GetWitnessHash(); });
|
||||
@ -1330,7 +1330,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
|
||||
const auto effective_feerate = args.m_package_feerates ? ws.m_package_feerate :
|
||||
CFeeRate{ws.m_modified_fees, static_cast<uint32_t>(ws.m_vsize)};
|
||||
const auto effective_feerate_wtxids = args.m_package_feerates ? all_package_wtxids :
|
||||
std::vector<uint256>{ws.m_ptx->GetWitnessHash()};
|
||||
std::vector<Wtxid>{ws.m_ptx->GetWitnessHash()};
|
||||
results.emplace(ws.m_ptx->GetWitnessHash(),
|
||||
MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions),
|
||||
ws.m_vsize, ws.m_base_fees, effective_feerate,
|
||||
|
@ -149,7 +149,7 @@ struct MempoolAcceptResult {
|
||||
* package. This is not necessarily equivalent to the list of transactions passed to
|
||||
* ProcessNewPackage().
|
||||
* Only present when m_result_type = ResultType::VALID. */
|
||||
const std::optional<std::vector<uint256>> m_wtxids_fee_calculations;
|
||||
const std::optional<std::vector<Wtxid>> m_wtxids_fee_calculations;
|
||||
|
||||
// The following field is only present when m_result_type = ResultType::DIFFERENT_WITNESS
|
||||
/** The wtxid of the transaction in the mempool which has the same txid but different witness. */
|
||||
@ -163,7 +163,7 @@ struct MempoolAcceptResult {
|
||||
int64_t vsize,
|
||||
CAmount fees,
|
||||
CFeeRate effective_feerate,
|
||||
const std::vector<uint256>& wtxids_fee_calculations) {
|
||||
const std::vector<Wtxid>& wtxids_fee_calculations) {
|
||||
return MempoolAcceptResult(std::move(replaced_txns), vsize, fees,
|
||||
effective_feerate, wtxids_fee_calculations);
|
||||
}
|
||||
@ -189,7 +189,7 @@ private:
|
||||
int64_t vsize,
|
||||
CAmount fees,
|
||||
CFeeRate effective_feerate,
|
||||
const std::vector<uint256>& wtxids_fee_calculations)
|
||||
const std::vector<Wtxid>& wtxids_fee_calculations)
|
||||
: m_result_type(ResultType::VALID),
|
||||
m_replaced_transactions(std::move(replaced_txns)),
|
||||
m_vsize{vsize},
|
||||
|
Loading…
x
Reference in New Issue
Block a user