mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 00:34:01 +02:00
Merge bitcoin/bitcoin#29752: refactor: Use typesafe Wtxid in compact block encodings
a8203e9412refactor: Simplify `extra_txn` to be a vec of CTransactionRef instead of a vec of pair<Wtxid, CTransactionRef> (AngusP)c3c18433aerefactor: Use typesafe Wtxid in compact block encoding message, instead of ambiguous uint256. (AngusP) Pull request description: The first commit replaces `uint256` with typesafe `Wtxid` (or `Txid`) types introduced in #28107. The second commit then simplifies the extra tx `vector` to just be of `CTransactionRef`s instead of a `std::pair<Wtxid, CTransactionRef>`, as it's easy to get a `Wtxid` from a transaction ref. ACKs for top commit: glozow: ACKa8203e9412dergoegge: ACKa8203e9412Tree-SHA512: b4ba1423a8059f9fc118782bd8a668213d229c822f22b01267de74d6ea97fe4f2aad46b5da7c0178ecc9905293e9a0eafba1d75330297c055e27fd53c8c8ebfd
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
std::vector<std::pair<uint256, CTransactionRef>> extra_txn;
|
||||
std::vector<CTransactionRef> extra_txn;
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(blockencodings_tests, RegTestingSetup)
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
explicit TestHeaderAndShortIDs(const CBlock& block) :
|
||||
TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs{block}) {}
|
||||
|
||||
uint64_t GetShortID(const uint256& txhash) const {
|
||||
uint64_t GetShortID(const Wtxid& txhash) const {
|
||||
DataStream stream{};
|
||||
stream << *this;
|
||||
CBlockHeaderAndShortTxIDs base;
|
||||
@@ -155,8 +155,8 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
|
||||
shortIDs.prefilledtxn.resize(1);
|
||||
shortIDs.prefilledtxn[0] = {1, block.vtx[1]};
|
||||
shortIDs.shorttxids.resize(2);
|
||||
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetHash());
|
||||
shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetHash());
|
||||
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetWitnessHash());
|
||||
shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetWitnessHash());
|
||||
|
||||
DataStream stream{};
|
||||
stream << shortIDs;
|
||||
@@ -226,7 +226,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
|
||||
shortIDs.prefilledtxn[0] = {0, block.vtx[0]};
|
||||
shortIDs.prefilledtxn[1] = {1, block.vtx[2]}; // id == 1 as it is 1 after index 1
|
||||
shortIDs.shorttxids.resize(1);
|
||||
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash());
|
||||
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetWitnessHash());
|
||||
|
||||
DataStream stream{};
|
||||
stream << shortIDs;
|
||||
|
||||
@@ -60,7 +60,7 @@ FUZZ_TARGET(partially_downloaded_block, .init = initialize_pdb)
|
||||
// The coinbase is always available
|
||||
available.insert(0);
|
||||
|
||||
std::vector<std::pair<uint256, CTransactionRef>> extra_txn;
|
||||
std::vector<CTransactionRef> extra_txn;
|
||||
for (size_t i = 1; i < block->vtx.size(); ++i) {
|
||||
auto tx{block->vtx[i]};
|
||||
|
||||
@@ -68,7 +68,7 @@ FUZZ_TARGET(partially_downloaded_block, .init = initialize_pdb)
|
||||
bool add_to_mempool{fuzzed_data_provider.ConsumeBool()};
|
||||
|
||||
if (add_to_extra_txn) {
|
||||
extra_txn.emplace_back(tx->GetWitnessHash(), tx);
|
||||
extra_txn.emplace_back(tx);
|
||||
available.insert(i);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user