diff --git a/src/blockencodings.h b/src/blockencodings.h --- a/src/blockencodings.h +++ b/src/blockencodings.h @@ -166,7 +166,7 @@ CBlockHeaderAndShortTxIDs(const CBlock &block); - uint64_t GetShortID(const uint256 &txhash) const; + uint64_t GetShortID(const TxHash &txhash) const; size_t BlockTxCount() const { return shorttxids.size() + prefilledtxn.size(); @@ -230,7 +230,7 @@ // reference> form. ReadStatus InitData(const CBlockHeaderAndShortTxIDs &cmpctblock, - const std::vector> &extra_txn); + const std::vector> &extra_txn); bool IsTxAvailable(size_t index) const; ReadStatus FillBlock(CBlock &block, const std::vector &vtx_missing); diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -42,7 +42,7 @@ shorttxidk1 = shorttxidhash.GetUint64(1); } -uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const uint256 &txhash) const { +uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const TxHash &txhash) const { static_assert(SHORTTXIDS_LENGTH == 6, "shorttxids calculation assumes 6-byte shorttxids"); return SipHashUint256(shorttxidk0, shorttxidk1, txhash) & 0xffffffffffffL; @@ -50,7 +50,7 @@ ReadStatus PartiallyDownloadedBlock::InitData( const CBlockHeaderAndShortTxIDs &cmpctblock, - const std::vector> &extra_txns) { + const std::vector> &extra_txns) { if (cmpctblock.header.IsNull() || (cmpctblock.shorttxids.empty() && cmpctblock.prefilledtxn.empty())) { return READ_STATUS_INVALID; @@ -131,7 +131,7 @@ std::vector have_txn(txns_available.size()); { LOCK(pool->cs); - const std::vector> &vTxHashes = + const std::vector> &vTxHashes = pool->vTxHashes; for (auto txHash : vTxHashes) { uint64_t shortid = cmpctblock.GetShortID(txHash.first); diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -217,7 +217,7 @@ mapOrphanTransactionsByPrev GUARDED_BY(g_cs_orphans); static size_t vExtraTxnForCompactIt GUARDED_BY(g_cs_orphans) = 0; -static std::vector> +static std::vector> vExtraTxnForCompact GUARDED_BY(g_cs_orphans); } // namespace @@ -976,7 +976,7 @@ } vExtraTxnForCompact[vExtraTxnForCompactIt] = - std::make_pair(tx->GetId(), tx); + std::make_pair(tx->GetHash(), tx); vExtraTxnForCompactIt = (vExtraTxnForCompactIt + 1) % max_extra_txn; } diff --git a/src/primitives/txid.h b/src/primitives/txid.h --- a/src/primitives/txid.h +++ b/src/primitives/txid.h @@ -20,6 +20,7 @@ * A TxHash is the double sha256 hash of the full transaction data. */ struct TxHash : public uint256 { + explicit TxHash() : uint256() {} explicit TxHash(const uint256 &b) : uint256(b) {} }; diff --git a/src/test/blockencodings_tests.cpp b/src/test/blockencodings_tests.cpp --- a/src/test/blockencodings_tests.cpp +++ b/src/test/blockencodings_tests.cpp @@ -15,7 +15,7 @@ #include -std::vector> extra_txn; +static std::vector> extra_txn; struct RegtestingSetup : public TestingSetup { RegtestingSetup() : TestingSetup(CBaseChainParams::REGTEST) {} @@ -150,7 +150,7 @@ explicit TestHeaderAndShortIDs(const CBlock &block) : TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs(block)) {} - uint64_t GetShortID(const uint256 &txhash) const { + uint64_t GetShortID(const TxHash &txhash) const { CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << *this; CBlockHeaderAndShortTxIDs base; @@ -197,8 +197,8 @@ shortIDs.prefilledtxn.resize(1); shortIDs.prefilledtxn[0] = {1, block.vtx[1]}; shortIDs.shorttxids.resize(2); - shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetId()); - shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetId()); + shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetHash()); + shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetHash()); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; @@ -294,7 +294,7 @@ // id == 1 as it is 1 after index 1 shortIDs.prefilledtxn[1] = {1, block.vtx[2]}; shortIDs.shorttxids.resize(1); - shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetId()); + shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash()); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -565,7 +565,7 @@ typedef indexed_transaction_set::nth_index<0>::type::iterator txiter; //!< All tx hashes/entries in mapTx, in random order - std::vector> vTxHashes; + std::vector> vTxHashes; struct CompareIteratorByHash { bool operator()(const txiter &a, const txiter &b) const {