scripted-diff: normalize CCoinsView naming

Standardize coins view naming with a mechanical rename pass.
This keeps subsequent commits focused on the interface and behavioral changes.

Co-authored-by: Andrew Toth <andrewstoth@gmail.com>

-BEGIN VERIFY SCRIPT-
git grep -qE '\bin_base\b|\bin_view\b|\bin_block_hash\b|\bblock_hash\b' -- src/coins.cpp src/coins.h src/txdb.cpp src/txdb.h src/test/coins_tests.cpp && { echo "Error: target names already exist in scoped files"; exit 1; }

perl -pi -e '
  s/\bbaseIn\b/in_base/g;
  s/\bhashBlockIn\b/in_block_hash/g;
  s/\bhashBlock\b/block_hash/g;
  s/\bviewIn\b/in_view/g;
  ' src/coins.cpp src/coins.h src/txdb.cpp src/txdb.h src/test/coins_tests.cpp
-END VERIFY SCRIPT-
This commit is contained in:
Lőrinc
2026-02-15 15:24:53 +01:00
parent 06172ef0d5
commit 38a99f3344
5 changed files with 35 additions and 35 deletions

View File

@@ -97,22 +97,22 @@ std::vector<uint256> CCoinsViewDB::GetHeadBlocks() const {
return vhashHeadBlocks;
}
void CCoinsViewDB::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& hashBlock)
void CCoinsViewDB::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash)
{
CDBBatch batch(*m_db);
size_t count = 0;
const size_t dirty_count{cursor.GetDirtyCount()};
assert(!hashBlock.IsNull());
assert(!block_hash.IsNull());
uint256 old_tip = GetBestBlock();
if (old_tip.IsNull()) {
// We may be in the middle of replaying.
std::vector<uint256> old_heads = GetHeadBlocks();
if (old_heads.size() == 2) {
if (old_heads[0] != hashBlock) {
if (old_heads[0] != block_hash) {
LogError("The coins database detected an inconsistent state, likely due to a previous crash or shutdown. You will need to restart bitcoind with the -reindex-chainstate or -reindex configuration option.\n");
}
assert(old_heads[0] == hashBlock);
assert(old_heads[0] == block_hash);
old_tip = old_heads[1];
}
}
@@ -122,11 +122,11 @@ void CCoinsViewDB::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& hashB
dirty_count, cursor.GetTotalCount()), BCLog::BENCH);
// In the first batch, mark the database as being in the middle of a
// transition from old_tip to hashBlock.
// transition from old_tip to block_hash.
// A vector is used for future extensibility, as we may want to support
// interrupting after partial writes from multiple independent reorgs.
batch.Erase(DB_BEST_BLOCK);
batch.Write(DB_HEAD_BLOCKS, Vector(hashBlock, old_tip));
batch.Write(DB_HEAD_BLOCKS, Vector(block_hash, old_tip));
for (auto it{cursor.Begin()}; it != cursor.End();) {
if (it->second.IsDirty()) {
@@ -154,9 +154,9 @@ void CCoinsViewDB::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& hashB
}
}
// In the last batch, mark the database as consistent with hashBlock again.
// In the last batch, mark the database as consistent with block_hash again.
batch.Erase(DB_HEAD_BLOCKS);
batch.Write(DB_BEST_BLOCK, hashBlock);
batch.Write(DB_BEST_BLOCK, block_hash);
LogDebug(BCLog::COINDB, "Writing final batch of %.2f MiB\n", batch.ApproximateSize() * (1.0 / 1048576.0));
m_db->WriteBatch(batch);
@@ -174,8 +174,8 @@ class CCoinsViewDBCursor: public CCoinsViewCursor
public:
// Prefer using CCoinsViewDB::Cursor() since we want to perform some
// cache warmup on instantiation.
CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256&hashBlockIn):
CCoinsViewCursor(hashBlockIn), pcursor(pcursorIn) {}
CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256&in_block_hash):
CCoinsViewCursor(in_block_hash), pcursor(pcursorIn) {}
~CCoinsViewDBCursor() = default;
bool GetKey(COutPoint &key) const override;