Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/blockencodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
6 changes: 3 additions & 3 deletions src/consensus/merkle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ uint256 BlockMerkleRoot(const CBlock& block, bool* mutated)
std::vector<uint256> 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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -185,7 +185,7 @@ std::vector<uint256> TransactionMerklePath(const CBlock& block, uint32_t positio
std::vector<uint256> 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);
}
2 changes: 1 addition & 1 deletion src/headerssync.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class HeadersSyncState {
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;
Expand Down
17 changes: 9 additions & 8 deletions src/index/txindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <index/disktxpos.h>
#include <logging.h>
#include <node/blockstorage.h>
#include <util/transaction_identifier.h>
#include <validation.h>

constexpr uint8_t DB_TXINDEX{'t'};
Expand All @@ -24,26 +25,26 @@ class TxIndex::DB : public BaseIndex::DB

/// 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<std::pair<uint256, CDiskTxPos>>& v_pos);
[[nodiscard]] bool WriteTxs(const std::vector<std::pair<Txid, CDiskTxPos>>& 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<std::pair<uint256, CDiskTxPos>>& v_pos)
bool TxIndex::DB::WriteTxs(const std::vector<std::pair<Txid, CDiskTxPos>>& v_pos)
{
CDBBatch batch(*this);
for (const auto& tuple : v_pos) {
batch.Write(std::make_pair(DB_TXINDEX, tuple.first), tuple.second);
batch.Write(std::make_pair(DB_TXINDEX, tuple.first.ToUint256()), tuple.second);
}
return WriteBatch(batch);
}
Expand All @@ -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<std::pair<uint256, CDiskTxPos>> vPos;
std::vector<std::pair<Txid, CDiskTxPos>> vPos;
vPos.reserve(block.data->vtx.size());
for (const auto& tx : block.data->vtx) {
vPos.emplace_back(tx->GetHash(), pos);
Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/index/txindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TxIndex final : public BaseIndex
/// @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.
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ class Chain
virtual RBFTransactionState isRBFOptIn(const CTransaction& tx) = 0;

//! Check if transaction is in mempool.
virtual bool isInMempool(const uint256& txid) = 0;
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.
Expand All @@ -222,7 +222,7 @@ class Chain
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
Expand Down
6 changes: 3 additions & 3 deletions src/kernel/coinstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static void ApplyHash(T& hash_obj, const Txid& hash, const std::map<uint32_t, Co
}
}

static void ApplyStats(CCoinsStats& stats, const uint256& hash, const std::map<uint32_t, Coin>& outputs)
static void ApplyStats(CCoinsStats& stats, const std::map<uint32_t, Coin>& outputs)
{
assert(!outputs.empty());
stats.nTransactions++;
Expand Down Expand Up @@ -126,7 +126,7 @@ static bool ComputeUTXOStats(CCoinsView* view, CCoinsStats& stats, T hash_obj, c
Coin coin;
if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
if (!outputs.empty() && key.hash != prevkey) {
ApplyStats(stats, prevkey, outputs);
ApplyStats(stats, outputs);
ApplyHash(hash_obj, prevkey, outputs);
outputs.clear();
}
Expand All @@ -140,7 +140,7 @@ static bool ComputeUTXOStats(CCoinsView* view, CCoinsStats& stats, T hash_obj, c
pcursor->Next();
}
if (!outputs.empty()) {
ApplyStats(stats, prevkey, outputs);
ApplyStats(stats, outputs);
ApplyHash(hash_obj, prevkey, outputs);
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernel/disconnected_transactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DisconnectedBlockTransactions {
const size_t m_max_mem_usage;
std::list<CTransactionRef> queuedTx;
using TxList = decltype(queuedTx);
std::unordered_map<uint256, TxList::iterator, SaltedTxidHasher> iters_by_txid;
std::unordered_map<Txid, TxList::iterator, SaltedTxidHasher> iters_by_txid;

/** Trim the earliest-added entries until we are within memory bounds. */
std::vector<CTransactionRef> LimitMemoryUsage();
Expand Down
4 changes: 2 additions & 2 deletions src/merkleblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ CMerkleBlock::CMerkleBlock(const CBlock& block, CBloomFilter* filter, const std:
vMatch.push_back(true);
} else if (filter && filter->IsRelevantAndUpdate(*block.vtx[i])) {
vMatch.push_back(true);
vMatchedTxn.emplace_back(i, hash);
vMatchedTxn.emplace_back(i, hash.ToUint256());
} else {
vMatch.push_back(false);
}
vHashes.push_back(hash);
vHashes.push_back(hash.ToUint256());
}

txn = CPartialMerkleTree(vHashes, vMatch);
Expand Down
Loading