aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2023-09-01 21:36:54 +0200
committerTheCharlatan <seb.kung@gmail.com>2023-11-10 16:44:44 +0100
commit55b0939cab49d50ca5bc59105b669e379d5e7f6c (patch)
treeffb1ab68304a308061af54a4a9e1cd13bca3c35d /src
parenta03aef9cec35b0d03aa63d7e8093f0420cd4b40b (diff)
downloadbitcoin-55b0939cab49d50ca5bc59105b669e379d5e7f6c.tar.xz
scripted-diff: rename vTxHashes to txns_randomized
-BEGIN VERIFY SCRIPT- git grep -l "vTxHashesIdx" src | xargs sed -i "s/vTxHashesIdx/idx_randomized/g" git grep -l "vTxHashes" src | xargs sed -i "s/vTxHashes/txns_randomized/g" -END VERIFY SCRIPT-
Diffstat (limited to 'src')
-rw-r--r--src/blockencodings.cpp2
-rw-r--r--src/kernel/mempool_entry.h2
-rw-r--r--src/test/blockencodings_tests.cpp2
-rw-r--r--src/txmempool.cpp24
-rw-r--r--src/txmempool.h2
5 files changed, 16 insertions, 16 deletions
diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp
index 9b8f49cbc8..29306b2229 100644
--- a/src/blockencodings.cpp
+++ b/src/blockencodings.cpp
@@ -107,7 +107,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
std::vector<bool> have_txn(txn_available.size());
{
LOCK(pool->cs);
- for (const auto& tx : pool->vTxHashes) {
+ for (const auto& tx : pool->txns_randomized) {
uint64_t shortid = cmpctblock.GetShortID(tx->GetWitnessHash());
std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(shortid);
if (idit != shorttxids.end()) {
diff --git a/src/kernel/mempool_entry.h b/src/kernel/mempool_entry.h
index c1478c0105..7c905ca4f4 100644
--- a/src/kernel/mempool_entry.h
+++ b/src/kernel/mempool_entry.h
@@ -172,7 +172,7 @@ public:
Parents& GetMemPoolParents() const { return m_parents; }
Children& GetMemPoolChildren() const { return m_children; }
- mutable size_t vTxHashesIdx; //!< Index in mempool's vTxHashes
+ mutable size_t idx_randomized; //!< Index in mempool's txns_randomized
mutable Epoch::Marker m_epoch_marker; //!< epoch when last touched, useful for graph algorithms
};
diff --git a/src/test/blockencodings_tests.cpp b/src/test/blockencodings_tests.cpp
index 33894fd076..e4ef019daf 100644
--- a/src/test/blockencodings_tests.cpp
+++ b/src/test/blockencodings_tests.cpp
@@ -51,7 +51,7 @@ static CBlock BuildBlockTestCase() {
}
// Number of shared use_counts we expect for a tx we haven't touched
-// (block + mempool entry + mempool vTxHashes + our copy from the GetSharedTx call)
+// (block + mempool entry + mempool txns_randomized + our copy from the GetSharedTx call)
constexpr long SHARED_TX_OFFSET{4};
BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 14f4d3c032..efcb77f47c 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -480,8 +480,8 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
minerPolicyEstimator->processTransaction(entry, validFeeEstimate);
}
- vTxHashes.emplace_back(newit->GetSharedTx());
- newit->vTxHashesIdx = vTxHashes.size() - 1;
+ txns_randomized.emplace_back(newit->GetSharedTx());
+ newit->idx_randomized = txns_randomized.size() - 1;
TRACE3(mempool, added,
entry.GetTx().GetHash().data(),
@@ -517,16 +517,16 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
RemoveUnbroadcastTx(hash, true /* add logging because unchecked */ );
- if (vTxHashes.size() > 1) {
- // Update vTxHashesIdx of the to-be-moved entry.
- Assert(GetEntry(vTxHashes.back()->GetHash()))->vTxHashesIdx = it->vTxHashesIdx;
- // Remove entry from vTxHashes by replacing it with the back and deleting the back.
- vTxHashes[it->vTxHashesIdx] = std::move(vTxHashes.back());
- vTxHashes.pop_back();
- if (vTxHashes.size() * 2 < vTxHashes.capacity())
- vTxHashes.shrink_to_fit();
+ if (txns_randomized.size() > 1) {
+ // Update idx_randomized of the to-be-moved entry.
+ Assert(GetEntry(txns_randomized.back()->GetHash()))->idx_randomized = it->idx_randomized;
+ // Remove entry from txns_randomized by replacing it with the back and deleting the back.
+ txns_randomized[it->idx_randomized] = std::move(txns_randomized.back());
+ txns_randomized.pop_back();
+ if (txns_randomized.size() * 2 < txns_randomized.capacity())
+ txns_randomized.shrink_to_fit();
} else
- vTxHashes.clear();
+ txns_randomized.clear();
totalTxSize -= it->GetTxSize();
m_total_fee -= it->GetFee();
@@ -1054,7 +1054,7 @@ void CCoinsViewMemPool::Reset()
size_t CTxMemPool::DynamicMemoryUsage() const {
LOCK(cs);
// Estimate the overhead of mapTx to be 15 pointers + an allocation, as no exact formula for boost::multi_index_contained is implemented.
- return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(vTxHashes) + cachedInnerUsage;
+ return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(txns_randomized) + cachedInnerUsage;
}
void CTxMemPool::RemoveUnbroadcastTx(const uint256& txid, const bool unchecked) {
diff --git a/src/txmempool.h b/src/txmempool.h
index fa1c62217b..3b0b8cf519 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -392,7 +392,7 @@ public:
indexed_transaction_set mapTx GUARDED_BY(cs);
using txiter = indexed_transaction_set::nth_index<0>::type::const_iterator;
- std::vector<CTransactionRef> vTxHashes GUARDED_BY(cs); //!< All transactions in mapTx, in random order
+ std::vector<CTransactionRef> txns_randomized GUARDED_BY(cs); //!< All transactions in mapTx, in random order
typedef std::set<txiter, CompareIteratorByHash> setEntries;