From a31252a8d8789f5743bb6aacf154844bda4cabc9 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 3 Jan 2023 19:55:05 +0000 Subject: [PATCH] txdb: Clean up for loop syntax in `WriteBatchSync` --- src/txdb.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index fe0245e53..5b3e83a4c 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -387,14 +387,14 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const { bool CBlockTreeDB::WriteBatchSync(const std::vector >& fileInfo, int nLastFile, const std::vector& blockinfo) { MetricsIncrementCounter("zcashd.debug.blocktree.write_batch"); CDBBatch batch(*this); - for (std::vector >::const_iterator it=fileInfo.begin(); it != fileInfo.end(); it++) { - batch.Write(make_pair(DB_BLOCK_FILES, it->first), *it->second); + for (const auto& it : fileInfo) { + batch.Write(make_pair(DB_BLOCK_FILES, it.first), *it.second); } batch.Write(DB_LAST_BLOCK, nLastFile); - for (std::vector::const_iterator it=blockinfo.begin(); it != blockinfo.end(); it++) { - std::pair key = make_pair(DB_BLOCK_INDEX, (*it)->GetBlockHash()); + for (const auto& it : blockinfo) { + std::pair key = make_pair(DB_BLOCK_INDEX, it->GetBlockHash()); try { - CDiskBlockIndex dbindex {*it, [this, &key]() { + CDiskBlockIndex dbindex {it, [this, &key]() { MetricsIncrementCounter("zcashd.debug.blocktree.write_batch_read_dbindex"); // It can happen that the index entry is written, then the Equihash solution is cleared from memory, // then the index entry is rewritten. In that case we must read the solution from the old entry.