diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp index 947f605d8e6..3f61a122e67 100644 --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -42,7 +42,7 @@ void CBlockHeaderAndShortTxIDs::FillShortTxIDSelector() const { uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const Wtxid& wtxid) const { static_assert(SHORTTXIDS_LENGTH == 6, "shorttxids calculation assumes 6-byte shorttxids"); - return SipHashUint256(shorttxidk0, shorttxidk1, wtxid) & 0xffffffffffffL; + return SipHashUint256(shorttxidk0, shorttxidk1, wtxid.ToUint256()) & 0xffffffffffffL; } ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& cmpctblock, const std::vector& extra_txn) { diff --git a/src/consensus/merkle.cpp b/src/consensus/merkle.cpp index 7dd24e1868f..e274ed821a5 100644 --- a/src/consensus/merkle.cpp +++ b/src/consensus/merkle.cpp @@ -68,7 +68,7 @@ uint256 BlockMerkleRoot(const CBlock& block, bool* mutated) std::vector leaves; leaves.resize(block.vtx.size()); for (size_t s = 0; s < block.vtx.size(); s++) { - leaves[s] = block.vtx[s]->GetHash(); + leaves[s] = block.vtx[s]->GetHash().ToUint256(); } return ComputeMerkleRoot(std::move(leaves), mutated); } @@ -79,7 +79,7 @@ uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated) leaves.resize(block.vtx.size()); leaves[0].SetNull(); // The witness hash of the coinbase is 0. for (size_t s = 1; s < block.vtx.size(); s++) { - leaves[s] = block.vtx[s]->GetWitnessHash(); + leaves[s] = block.vtx[s]->GetWitnessHash().ToUint256(); } return ComputeMerkleRoot(std::move(leaves), mutated); } @@ -185,7 +185,7 @@ std::vector TransactionMerklePath(const CBlock& block, uint32_t positio std::vector leaves; leaves.resize(block.vtx.size()); for (size_t s = 0; s < block.vtx.size(); s++) { - leaves[s] = block.vtx[s]->GetHash(); + leaves[s] = block.vtx[s]->GetHash().ToUint256(); } return ComputeMerklePath(leaves, position); } diff --git a/src/headerssync.cpp b/src/headerssync.cpp index 9e8b1905168..fbe2026ecae 100644 --- a/src/headerssync.cpp +++ b/src/headerssync.cpp @@ -48,7 +48,7 @@ HeadersSyncState::HeadersSyncState(NodeId id, const Consensus::Params& consensus /** Free any memory in use, and mark this object as no longer usable. This is * required to guarantee that we won't reuse this object with the same - * SaltedTxidHasher for another sync. */ + * SaltedUint256Hasher for another sync. */ void HeadersSyncState::Finalize() { Assume(m_download_state != State::FINAL); diff --git a/src/headerssync.h b/src/headerssync.h index 2e7017f115d..56380c66fe2 100644 --- a/src/headerssync.h +++ b/src/headerssync.h @@ -224,7 +224,7 @@ private: arith_uint256 m_current_chain_work; /** m_hasher is a salted hasher for making our 1-bit commitments to headers we've seen. */ - const SaltedTxidHasher m_hasher; + const SaltedUint256Hasher m_hasher; /** A queue of commitment bits, created during the 1st phase, and verified during the 2nd. */ bitdeque<> m_header_commitments; diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp index 4bb6dc74447..11dd856e1b6 100644 --- a/src/index/txindex.cpp +++ b/src/index/txindex.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include constexpr uint8_t DB_TXINDEX{'t'}; @@ -24,26 +25,26 @@ public: /// Read the disk location of the transaction data with the given hash. Returns false if the /// transaction hash is not indexed. - bool ReadTxPos(const uint256& txid, CDiskTxPos& pos) const; + bool ReadTxPos(const Txid& txid, CDiskTxPos& pos) const; /// Write a batch of transaction positions to the DB. - [[nodiscard]] bool WriteTxs(const std::vector>& v_pos); + [[nodiscard]] bool WriteTxs(const std::vector>& v_pos); }; TxIndex::DB::DB(size_t n_cache_size, bool f_memory, bool f_wipe) : BaseIndex::DB(gArgs.GetDataDirNet() / "indexes" / "txindex", n_cache_size, f_memory, f_wipe) {} -bool TxIndex::DB::ReadTxPos(const uint256 &txid, CDiskTxPos& pos) const +bool TxIndex::DB::ReadTxPos(const Txid& txid, CDiskTxPos& pos) const { - return Read(std::make_pair(DB_TXINDEX, txid), pos); + return Read(std::make_pair(DB_TXINDEX, txid.ToUint256()), pos); } -bool TxIndex::DB::WriteTxs(const std::vector>& v_pos) +bool TxIndex::DB::WriteTxs(const std::vector>& v_pos) { CDBBatch batch(*this); - for (const auto& tuple : v_pos) { - batch.Write(std::make_pair(DB_TXINDEX, tuple.first), tuple.second); + for (const auto& [txid, pos] : v_pos) { + batch.Write(std::make_pair(DB_TXINDEX, txid.ToUint256()), pos); } return WriteBatch(batch); } @@ -61,7 +62,7 @@ bool TxIndex::CustomAppend(const interfaces::BlockInfo& block) assert(block.data); CDiskTxPos pos({block.file_number, block.data_pos}, GetSizeOfCompactSize(block.data->vtx.size())); - std::vector> vPos; + std::vector> vPos; vPos.reserve(block.data->vtx.size()); for (const auto& tx : block.data->vtx) { vPos.emplace_back(tx->GetHash(), pos); @@ -72,7 +73,7 @@ bool TxIndex::CustomAppend(const interfaces::BlockInfo& block) BaseIndex::DB& TxIndex::GetDB() const { return *m_db; } -bool TxIndex::FindTx(const uint256& tx_hash, uint256& block_hash, CTransactionRef& tx) const +bool TxIndex::FindTx(const Txid& tx_hash, uint256& block_hash, CTransactionRef& tx) const { CDiskTxPos postx; if (!m_db->ReadTxPos(tx_hash, postx)) { diff --git a/src/index/txindex.h b/src/index/txindex.h index ef835fe5d7d..f8236c92844 100644 --- a/src/index/txindex.h +++ b/src/index/txindex.h @@ -42,7 +42,7 @@ public: /// @param[out] block_hash The hash of the block the transaction is found in. /// @param[out] tx The transaction itself. /// @return true if transaction is found, false otherwise - bool FindTx(const uint256& tx_hash, uint256& block_hash, CTransactionRef& tx) const; + bool FindTx(const Txid& tx_hash, uint256& block_hash, CTransactionRef& tx) const; }; /// The global transaction index, used in GetTransaction. May be null. diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 56716ec673f..82bfdb9fd30 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -211,7 +211,7 @@ public: virtual bool isInMempool(const Txid& txid) = 0; //! Check if transaction has descendants in mempool. - virtual bool hasDescendantsInMempool(const uint256& txid) = 0; + virtual bool hasDescendantsInMempool(const Txid& txid) = 0; //! Transaction is added to memory pool, if the transaction fee is below the //! amount specified by max_tx_fee, and broadcast to all peers if relay is set to true. @@ -222,7 +222,7 @@ public: std::string& err_string) = 0; //! Calculate mempool ancestor and descendant counts for the given transaction. - virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) = 0; + virtual void getTransactionAncestry(const Txid& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) = 0; //! For each outpoint, calculate the fee-bumping cost to spend this outpoint at the specified // feerate, including bumping its ancestors. For example, if the target feerate is 10sat/vbyte diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 94869aff5af..412cbb613e3 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -9,12 +9,12 @@ #include #include #include +#include #include #include