Fixup style of moved code

Can be reviewed with --word-diff-regex=.
This commit is contained in:
MarcoFalke
2023-08-01 12:33:09 +02:00
parent fa65111b99
commit faf63039cc

View File

@ -38,45 +38,54 @@ static constexpr uint8_t DB_LAST_BLOCK{'l'};
// CBlockTreeDB::DB_TXINDEX{'t'} // CBlockTreeDB::DB_TXINDEX{'t'}
// CBlockTreeDB::ReadFlag("txindex") // CBlockTreeDB::ReadFlag("txindex")
bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) { bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo& info)
{
return Read(std::make_pair(DB_BLOCK_FILES, nFile), info); return Read(std::make_pair(DB_BLOCK_FILES, nFile), info);
} }
bool CBlockTreeDB::WriteReindexing(bool fReindexing) { bool CBlockTreeDB::WriteReindexing(bool fReindexing)
if (fReindexing) {
if (fReindexing) {
return Write(DB_REINDEX_FLAG, uint8_t{'1'}); return Write(DB_REINDEX_FLAG, uint8_t{'1'});
else } else {
return Erase(DB_REINDEX_FLAG); return Erase(DB_REINDEX_FLAG);
}
} }
void CBlockTreeDB::ReadReindexing(bool &fReindexing) { void CBlockTreeDB::ReadReindexing(bool& fReindexing)
{
fReindexing = Exists(DB_REINDEX_FLAG); fReindexing = Exists(DB_REINDEX_FLAG);
} }
bool CBlockTreeDB::ReadLastBlockFile(int &nFile) { bool CBlockTreeDB::ReadLastBlockFile(int& nFile)
{
return Read(DB_LAST_BLOCK, nFile); return Read(DB_LAST_BLOCK, nFile);
} }
bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo) { bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*>>& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo)
{
CDBBatch batch(*this); CDBBatch batch(*this);
for (std::vector<std::pair<int, const CBlockFileInfo*> >::const_iterator it=fileInfo.begin(); it != fileInfo.end(); it++) { for (const auto& [file, info] : fileInfo) {
batch.Write(std::make_pair(DB_BLOCK_FILES, it->first), *it->second); batch.Write(std::make_pair(DB_BLOCK_FILES, file), *info);
} }
batch.Write(DB_LAST_BLOCK, nLastFile); batch.Write(DB_LAST_BLOCK, nLastFile);
for (std::vector<const CBlockIndex*>::const_iterator it=blockinfo.begin(); it != blockinfo.end(); it++) { for (const CBlockIndex* bi : blockinfo) {
batch.Write(std::make_pair(DB_BLOCK_INDEX, (*it)->GetBlockHash()), CDiskBlockIndex(*it)); batch.Write(std::make_pair(DB_BLOCK_INDEX, bi->GetBlockHash()), CDiskBlockIndex{bi});
} }
return WriteBatch(batch, true); return WriteBatch(batch, true);
} }
bool CBlockTreeDB::WriteFlag(const std::string &name, bool fValue) { bool CBlockTreeDB::WriteFlag(const std::string& name, bool fValue)
{
return Write(std::make_pair(DB_FLAG, name), fValue ? uint8_t{'1'} : uint8_t{'0'}); return Write(std::make_pair(DB_FLAG, name), fValue ? uint8_t{'1'} : uint8_t{'0'});
} }
bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) { bool CBlockTreeDB::ReadFlag(const std::string& name, bool& fValue)
{
uint8_t ch; uint8_t ch;
if (!Read(std::make_pair(DB_FLAG, name), ch)) if (!Read(std::make_pair(DB_FLAG, name), ch)) {
return false; return false;
}
fValue = ch == uint8_t{'1'}; fValue = ch == uint8_t{'1'};
return true; return true;
} }