Skip to content

Commit 55b0939

Browse files
committed
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-
1 parent a03aef9 commit 55b0939

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/blockencodings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
107107
std::vector<bool> have_txn(txn_available.size());
108108
{
109109
LOCK(pool->cs);
110-
for (const auto& tx : pool->vTxHashes) {
110+
for (const auto& tx : pool->txns_randomized) {
111111
uint64_t shortid = cmpctblock.GetShortID(tx->GetWitnessHash());
112112
std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(shortid);
113113
if (idit != shorttxids.end()) {

src/kernel/mempool_entry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class CTxMemPoolEntry
172172
Parents& GetMemPoolParents() const { return m_parents; }
173173
Children& GetMemPoolChildren() const { return m_children; }
174174

175-
mutable size_t vTxHashesIdx; //!< Index in mempool's vTxHashes
175+
mutable size_t idx_randomized; //!< Index in mempool's txns_randomized
176176
mutable Epoch::Marker m_epoch_marker; //!< epoch when last touched, useful for graph algorithms
177177
};
178178

src/test/blockencodings_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static CBlock BuildBlockTestCase() {
5151
}
5252

5353
// Number of shared use_counts we expect for a tx we haven't touched
54-
// (block + mempool entry + mempool vTxHashes + our copy from the GetSharedTx call)
54+
// (block + mempool entry + mempool txns_randomized + our copy from the GetSharedTx call)
5555
constexpr long SHARED_TX_OFFSET{4};
5656

5757
BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)

src/txmempool.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
480480
minerPolicyEstimator->processTransaction(entry, validFeeEstimate);
481481
}
482482

483-
vTxHashes.emplace_back(newit->GetSharedTx());
484-
newit->vTxHashesIdx = vTxHashes.size() - 1;
483+
txns_randomized.emplace_back(newit->GetSharedTx());
484+
newit->idx_randomized = txns_randomized.size() - 1;
485485

486486
TRACE3(mempool, added,
487487
entry.GetTx().GetHash().data(),
@@ -517,16 +517,16 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
517517

518518
RemoveUnbroadcastTx(hash, true /* add logging because unchecked */ );
519519

520-
if (vTxHashes.size() > 1) {
521-
// Update vTxHashesIdx of the to-be-moved entry.
522-
Assert(GetEntry(vTxHashes.back()->GetHash()))->vTxHashesIdx = it->vTxHashesIdx;
523-
// Remove entry from vTxHashes by replacing it with the back and deleting the back.
524-
vTxHashes[it->vTxHashesIdx] = std::move(vTxHashes.back());
525-
vTxHashes.pop_back();
526-
if (vTxHashes.size() * 2 < vTxHashes.capacity())
527-
vTxHashes.shrink_to_fit();
520+
if (txns_randomized.size() > 1) {
521+
// Update idx_randomized of the to-be-moved entry.
522+
Assert(GetEntry(txns_randomized.back()->GetHash()))->idx_randomized = it->idx_randomized;
523+
// Remove entry from txns_randomized by replacing it with the back and deleting the back.
524+
txns_randomized[it->idx_randomized] = std::move(txns_randomized.back());
525+
txns_randomized.pop_back();
526+
if (txns_randomized.size() * 2 < txns_randomized.capacity())
527+
txns_randomized.shrink_to_fit();
528528
} else
529-
vTxHashes.clear();
529+
txns_randomized.clear();
530530

531531
totalTxSize -= it->GetTxSize();
532532
m_total_fee -= it->GetFee();
@@ -1054,7 +1054,7 @@ void CCoinsViewMemPool::Reset()
10541054
size_t CTxMemPool::DynamicMemoryUsage() const {
10551055
LOCK(cs);
10561056
// Estimate the overhead of mapTx to be 15 pointers + an allocation, as no exact formula for boost::multi_index_contained is implemented.
1057-
return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(vTxHashes) + cachedInnerUsage;
1057+
return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(txns_randomized) + cachedInnerUsage;
10581058
}
10591059

10601060
void CTxMemPool::RemoveUnbroadcastTx(const uint256& txid, const bool unchecked) {

src/txmempool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class CTxMemPool
392392
indexed_transaction_set mapTx GUARDED_BY(cs);
393393

394394
using txiter = indexed_transaction_set::nth_index<0>::type::const_iterator;
395-
std::vector<CTransactionRef> vTxHashes GUARDED_BY(cs); //!< All transactions in mapTx, in random order
395+
std::vector<CTransactionRef> txns_randomized GUARDED_BY(cs); //!< All transactions in mapTx, in random order
396396

397397
typedef std::set<txiter, CompareIteratorByHash> setEntries;
398398

0 commit comments

Comments
 (0)