Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#28691: refactor: Remove CBlockFileInfo::SetNull
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fanquake committed Oct 23, 2023
2 parents 0f15db0 + fac36b9 commit f4e96c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
30 changes: 8 additions & 22 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ static constexpr int64_t MAX_BLOCK_TIME_GAP = 90 * 60;
class CBlockFileInfo
{
public:
unsigned int nBlocks; //!< number of blocks stored in file
unsigned int nSize; //!< number of used bytes of block file
unsigned int nUndoSize; //!< number of used bytes in the undo file
unsigned int nHeightFirst; //!< lowest height of block in file
unsigned int nHeightLast; //!< highest height of block in file
uint64_t nTimeFirst; //!< earliest time of block in file
uint64_t nTimeLast; //!< latest time of block in file
unsigned int nBlocks{}; //!< number of blocks stored in file
unsigned int nSize{}; //!< number of used bytes of block file
unsigned int nUndoSize{}; //!< number of used bytes in the undo file
unsigned int nHeightFirst{}; //!< lowest height of block in file
unsigned int nHeightLast{}; //!< highest height of block in file
uint64_t nTimeFirst{}; //!< earliest time of block in file
uint64_t nTimeLast{}; //!< latest time of block in file

SERIALIZE_METHODS(CBlockFileInfo, obj)
{
Expand All @@ -61,21 +61,7 @@ class CBlockFileInfo
READWRITE(VARINT(obj.nTimeLast));
}

void SetNull()
{
nBlocks = 0;
nSize = 0;
nUndoSize = 0;
nHeightFirst = 0;
nHeightLast = 0;
nTimeFirst = 0;
nTimeLast = 0;
}

CBlockFileInfo()
{
SetNull();
}
CBlockFileInfo() {}

std::string ToString() const;

Expand Down
2 changes: 1 addition & 1 deletion src/node/blockstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
}
}

m_blockfile_info[fileNumber].SetNull();
m_blockfile_info.at(fileNumber) = CBlockFileInfo{};
m_dirty_fileinfo.insert(fileNumber);
}

Expand Down
1 change: 0 additions & 1 deletion src/node/blockstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
class BlockValidationState;
class CAutoFile;
class CBlock;
class CBlockFileInfo;
class CBlockUndo;
class CChainParams;
class Chainstate;
Expand Down

0 comments on commit f4e96c2

Please sign in to comment.