mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 02:02:42 +02:00
Merge bitcoin/bitcoin#33116: refactor: Convert uint256 to Txid
de0675f9derefactor: Move `transaction_identifier.h` to primitives (marcofleon)6f068f65deRemove implicit uint256 conversion and comparison (marcofleon)9c24cda72erefactor: Convert remaining instances from uint256 to Txid (marcofleon)d2ecd6815dpolicy, refactor: Convert uint256 to Txid (marcofleon)f6c0d1d231mempool, refactor: Convert uint256 to Txid (marcofleon)aeb0f78330refactor: Convert `mini_miner` from uint256 to Txid (marcofleon)326f244724refactor: Convert RPCs and `merkleblock` from uint256 to Txid (marcofleon)49b3d3a92aClean up `FindTxForGetData` (marcofleon) Pull request description: This is the final leg of the [type safety refactor](https://github.com/bitcoin/bitcoin/pull/32189). All of these changes are straightforward `uint256` --> `Txid` along with any necessary explicit conversions. Also, `transaction_identifier.h` is moved to primitives in the last commit, as `Txid` and `Wtxid` become fundamental types after this PR. ACKs for top commit: stickies-v: re-ACKde0675f9de, no changes since a20724d926d5844168c6a13fa8293df8c8927efe except address review nits. janb84: re ACKde0675f9dedergoegge: re-ACKde0675f9detheStack: Code-review ACKde0675f9deTree-SHA512: 2413160fca7ab146a8d79d18ce3afcf7384cacc73c513d41928904aa453b4dd7a350064cee71e9c5d015da5904c7c81ac17603e50a47441ebc5b0c653235dd08
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
|
||||
#include <core_io.h>
|
||||
#include <primitives/block.h>
|
||||
#include <primitives/transaction_identifier.h>
|
||||
#include <pubkey.h>
|
||||
#include <rpc/util.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <uint256.h>
|
||||
#include <univalue.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/transaction_identifier.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
@@ -19,7 +19,7 @@ uint256 ComputeMerkleRootFromPath(const CBlock& block, uint32_t position, const
|
||||
throw std::out_of_range("Position out of range");
|
||||
}
|
||||
|
||||
uint256 current_hash = block.vtx[position]->GetHash();
|
||||
uint256 current_hash = block.vtx[position]->GetHash().ToUint256();
|
||||
|
||||
for (const uint256& sibling : merkle_path) {
|
||||
if (position % 2 == 0) {
|
||||
@@ -47,7 +47,7 @@ FUZZ_TARGET(merkle)
|
||||
tx_hashes.reserve(num_txs);
|
||||
|
||||
for (size_t i = 0; i < num_txs; ++i) {
|
||||
tx_hashes.push_back(block->vtx[i]->GetHash());
|
||||
tx_hashes.push_back(block->vtx[i]->GetHash().ToUint256());
|
||||
}
|
||||
|
||||
// Test ComputeMerkleRoot
|
||||
|
||||
@@ -43,7 +43,7 @@ FUZZ_TARGET(merkleblock)
|
||||
partial_merkle_tree = merkle_block.txn;
|
||||
});
|
||||
(void)partial_merkle_tree.GetNumTransactions();
|
||||
std::vector<uint256> matches;
|
||||
std::vector<Txid> matches;
|
||||
std::vector<unsigned int> indices;
|
||||
(void)partial_merkle_tree.ExtractMatches(matches, indices);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ CBlock ConsumeBlock(FuzzedDataProvider& fuzzed_data_provider, const uint256& pre
|
||||
tx.vout[0].nValue = 0;
|
||||
tx.vin[0].scriptSig.resize(2);
|
||||
block.vtx.push_back(MakeTransactionRef(tx));
|
||||
block.hashMerkleRoot = block.vtx[0]->GetHash();
|
||||
block.hashMerkleRoot = block.vtx[0]->GetHash().ToUint256();
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool)
|
||||
if (tx_pool.exists(txid)) {
|
||||
const auto tx_info{tx_pool.info(txid)};
|
||||
if (GetDust(*tx_info.tx, tx_pool.m_opts.dust_relay_feerate).empty()) {
|
||||
tx_pool.PrioritiseTransaction(txid.ToUint256(), delta);
|
||||
tx_pool.PrioritiseTransaction(txid, delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -477,7 +477,7 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
|
||||
txs.back()->GetHash() :
|
||||
PickValue(fuzzed_data_provider, mempool_outpoints).hash;
|
||||
const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
|
||||
tx_pool.PrioritiseTransaction(txid.ToUint256(), delta);
|
||||
tx_pool.PrioritiseTransaction(txid, delta);
|
||||
}
|
||||
|
||||
// Remember all added transactions
|
||||
|
||||
@@ -85,7 +85,7 @@ FUZZ_TARGET(policy_estimator, .init = initialize_policy_estimator)
|
||||
block_policy_estimator.processBlock(txs, current_height);
|
||||
},
|
||||
[&] {
|
||||
(void)block_policy_estimator.removeTx(ConsumeUInt256(fuzzed_data_provider));
|
||||
(void)block_policy_estimator.removeTx(Txid::FromUint256(ConsumeUInt256(fuzzed_data_provider)));
|
||||
},
|
||||
[&] {
|
||||
block_policy_estimator.FlushUnconfirmed();
|
||||
|
||||
@@ -160,7 +160,7 @@ FUZZ_TARGET(package_rbf, .init = initialize_package_rbf)
|
||||
}
|
||||
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
pool.PrioritiseTransaction(mempool_txs.back().GetHash().ToUint256(), fuzzed_data_provider.ConsumeIntegralInRange<int32_t>(-100000, 100000));
|
||||
pool.PrioritiseTransaction(mempool_txs.back().GetHash(), fuzzed_data_provider.ConsumeIntegralInRange<int32_t>(-100000, 100000));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
|
||||
tx->GetHash() :
|
||||
PickValue(fuzzed_data_provider, outpoints_rbf).hash;
|
||||
const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
|
||||
tx_pool.PrioritiseTransaction(txid.ToUint256(), delta);
|
||||
tx_pool.PrioritiseTransaction(txid, delta);
|
||||
}
|
||||
|
||||
// Remember all removed and added transactions
|
||||
@@ -409,7 +409,7 @@ FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
|
||||
mut_tx.GetHash() :
|
||||
PickValue(fuzzed_data_provider, txids);
|
||||
const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
|
||||
tx_pool.PrioritiseTransaction(txid.ToUint256(), delta);
|
||||
tx_pool.PrioritiseTransaction(txid, delta);
|
||||
}
|
||||
|
||||
const auto tx = MakeTransactionRef(mut_tx);
|
||||
|
||||
Reference in New Issue
Block a user