aboutsummaryrefslogtreecommitdiff
path: root/src/node/blockstorage.h
diff options
context:
space:
mode:
authorMartin Zumsande <mzumsande@gmail.com>2024-03-20 15:05:08 -0400
committerMartin Zumsande <mzumsande@gmail.com>2024-05-14 14:54:26 -0400
commit064859bbad6984a6ec85c744064abdf757807c58 (patch)
tree929e949971ec70058d4b465ed7f4b5ca346df29c /src/node/blockstorage.h
parentfdae638e83522c28a1222e65c43d1cbca3e34cba (diff)
downloadbitcoin-064859bbad6984a6ec85c744064abdf757807c58.tar.xz
blockstorage: split up FindBlockPos function
FindBlockPos does different things depending on whether the block is known or not, as shown by the fact that much of the existing code is conditional on fKnown set or not. If the block position is known (during reindex) the function only updates the block info statistics. It doesn't actually find a block position in this case. This commit removes fKnown and splits up these two code paths by introducing a separate function for the reindex case when the block position is known. It doesn't change behavior.
Diffstat (limited to 'src/node/blockstorage.h')
-rw-r--r--src/node/blockstorage.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
index 27b7737051..ff77a66b3b 100644
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -161,11 +161,10 @@ private:
* block file depending on nAddSize. May flush the previous blockfile to disk if full, updates
* blockfile info, and checks if there is enough disk space to save the block.
*
- * If fKnown is false, the nAddSize argument passed to this function should include not just the size of the serialized CBlock, but also the size of
+ * The nAddSize argument passed to this function should include not just the size of the serialized CBlock, but also the size of
* separator fields which are written before it by WriteBlockToDisk (BLOCK_SERIALIZATION_HEADER_SIZE).
- * If fKnown is true, nAddSize should be just the size of the serialized CBlock.
*/
- [[nodiscard]] bool FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown);
+ [[nodiscard]] bool FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime);
[[nodiscard]] bool FlushChainstateBlockFile(int tip_height);
bool FindUndoPos(BlockValidationState& state, int nFile, FlatFilePos& pos, unsigned int nAddSize);
@@ -340,6 +339,15 @@ public:
*/
FlatFilePos SaveBlockToDisk(const CBlock& block, int nHeight, const FlatFilePos* dbp);
+ /** Update blockfile info while processing a block during reindex. The block must be available on disk.
+ *
+ * @param[in] block the block being processed
+ * @param[in] nHeight the height of the block
+ * @param[in] pos the position of the serialized CBlock on disk. This is the position returned
+ * by WriteBlockToDisk pointing at the CBlock, not the separator fields before it
+ */
+ void UpdateBlockInfo(const CBlock& block, unsigned int nHeight, const FlatFilePos& pos);
+
/** Whether running in -prune mode. */
[[nodiscard]] bool IsPruneMode() const { return m_prune_mode; }