Skip to content

Commit f4e96c2

Browse files
committed
Merge bitcoin#28691: refactor: Remove CBlockFileInfo::SetNull
fac36b9 refactor: Remove CBlockFileInfo::SetNull (MarcoFalke) Pull request description: Seems better to use C++11 member initializers and then let the compiler figure out how to construct objects of this class. ACKs for top commit: stickies-v: ACK fac36b9 pablomartin4btc: ACK fac36b9 theStack: LGTM ACK fac36b9 Tree-SHA512: aee741c8f668f0e5b658fc83f4ebd196b43fead3dd437afdb0a2dafe092ae3d559332b3d9d61985c92e1a59982d8f24942606e6a98598c6ef7ff43697e858725
2 parents 0f15db0 + fac36b9 commit f4e96c2

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

src/chain.h

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ static constexpr int64_t MAX_BLOCK_TIME_GAP = 90 * 60;
4242
class CBlockFileInfo
4343
{
4444
public:
45-
unsigned int nBlocks; //!< number of blocks stored in file
46-
unsigned int nSize; //!< number of used bytes of block file
47-
unsigned int nUndoSize; //!< number of used bytes in the undo file
48-
unsigned int nHeightFirst; //!< lowest height of block in file
49-
unsigned int nHeightLast; //!< highest height of block in file
50-
uint64_t nTimeFirst; //!< earliest time of block in file
51-
uint64_t nTimeLast; //!< latest time of block in file
45+
unsigned int nBlocks{}; //!< number of blocks stored in file
46+
unsigned int nSize{}; //!< number of used bytes of block file
47+
unsigned int nUndoSize{}; //!< number of used bytes in the undo file
48+
unsigned int nHeightFirst{}; //!< lowest height of block in file
49+
unsigned int nHeightLast{}; //!< highest height of block in file
50+
uint64_t nTimeFirst{}; //!< earliest time of block in file
51+
uint64_t nTimeLast{}; //!< latest time of block in file
5252

5353
SERIALIZE_METHODS(CBlockFileInfo, obj)
5454
{
@@ -61,21 +61,7 @@ class CBlockFileInfo
6161
READWRITE(VARINT(obj.nTimeLast));
6262
}
6363

64-
void SetNull()
65-
{
66-
nBlocks = 0;
67-
nSize = 0;
68-
nUndoSize = 0;
69-
nHeightFirst = 0;
70-
nHeightLast = 0;
71-
nTimeFirst = 0;
72-
nTimeLast = 0;
73-
}
74-
75-
CBlockFileInfo()
76-
{
77-
SetNull();
78-
}
64+
CBlockFileInfo() {}
7965

8066
std::string ToString() const;
8167

src/node/blockstorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
254254
}
255255
}
256256

257-
m_blockfile_info[fileNumber].SetNull();
257+
m_blockfile_info.at(fileNumber) = CBlockFileInfo{};
258258
m_dirty_fileinfo.insert(fileNumber);
259259
}
260260

src/node/blockstorage.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
class BlockValidationState;
3333
class CAutoFile;
3434
class CBlock;
35-
class CBlockFileInfo;
3635
class CBlockUndo;
3736
class CChainParams;
3837
class Chainstate;

0 commit comments

Comments
 (0)