@@ -38,45 +38,54 @@ static constexpr uint8_t DB_LAST_BLOCK{'l'};
38
38
// CBlockTreeDB::DB_TXINDEX{'t'}
39
39
// CBlockTreeDB::ReadFlag("txindex")
40
40
41
- bool CBlockTreeDB::ReadBlockFileInfo (int nFile, CBlockFileInfo &info) {
41
+ bool CBlockTreeDB::ReadBlockFileInfo (int nFile, CBlockFileInfo& info)
42
+ {
42
43
return Read (std::make_pair (DB_BLOCK_FILES, nFile), info);
43
44
}
44
45
45
- bool CBlockTreeDB::WriteReindexing (bool fReindexing ) {
46
- if (fReindexing )
46
+ bool CBlockTreeDB::WriteReindexing (bool fReindexing )
47
+ {
48
+ if (fReindexing ) {
47
49
return Write (DB_REINDEX_FLAG, uint8_t {' 1' });
48
- else
50
+ } else {
49
51
return Erase (DB_REINDEX_FLAG);
52
+ }
50
53
}
51
54
52
- void CBlockTreeDB::ReadReindexing (bool &fReindexing ) {
55
+ void CBlockTreeDB::ReadReindexing (bool & fReindexing )
56
+ {
53
57
fReindexing = Exists (DB_REINDEX_FLAG);
54
58
}
55
59
56
- bool CBlockTreeDB::ReadLastBlockFile (int &nFile) {
60
+ bool CBlockTreeDB::ReadLastBlockFile (int & nFile)
61
+ {
57
62
return Read (DB_LAST_BLOCK, nFile);
58
63
}
59
64
60
- bool CBlockTreeDB::WriteBatchSync (const std::vector<std::pair<int , const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo) {
65
+ bool CBlockTreeDB::WriteBatchSync (const std::vector<std::pair<int , const CBlockFileInfo*>>& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo)
66
+ {
61
67
CDBBatch batch (*this );
62
- for (std::vector<std::pair< int , const CBlockFileInfo*> >::const_iterator it=fileInfo. begin (); it != fileInfo. end (); it++ ) {
63
- batch.Write (std::make_pair (DB_BLOCK_FILES, it-> first ), *it-> second );
68
+ for (const auto & [file, info] : fileInfo) {
69
+ batch.Write (std::make_pair (DB_BLOCK_FILES, file ), *info );
64
70
}
65
71
batch.Write (DB_LAST_BLOCK, nLastFile);
66
- for (std::vector< const CBlockIndex*>::const_iterator it=blockinfo. begin (); it != blockinfo. end (); it++ ) {
67
- batch.Write (std::make_pair (DB_BLOCK_INDEX, (*it) ->GetBlockHash ()), CDiskBlockIndex (*it) );
72
+ for (const CBlockIndex* bi : blockinfo) {
73
+ batch.Write (std::make_pair (DB_BLOCK_INDEX, bi ->GetBlockHash ()), CDiskBlockIndex{bi} );
68
74
}
69
75
return WriteBatch (batch, true );
70
76
}
71
77
72
- bool CBlockTreeDB::WriteFlag (const std::string &name, bool fValue ) {
78
+ bool CBlockTreeDB::WriteFlag (const std::string& name, bool fValue )
79
+ {
73
80
return Write (std::make_pair (DB_FLAG, name), fValue ? uint8_t {' 1' } : uint8_t {' 0' });
74
81
}
75
82
76
- bool CBlockTreeDB::ReadFlag (const std::string &name, bool &fValue ) {
83
+ bool CBlockTreeDB::ReadFlag (const std::string& name, bool & fValue )
84
+ {
77
85
uint8_t ch;
78
- if (!Read (std::make_pair (DB_FLAG, name), ch))
86
+ if (!Read (std::make_pair (DB_FLAG, name), ch)) {
79
87
return false ;
88
+ }
80
89
fValue = ch == uint8_t {' 1' };
81
90
return true ;
82
91
}
0 commit comments