aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-05-04 12:30:34 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-05-04 19:26:48 +0200
commitfa3f74a40efa0db3af31438e9250c41bc7406749 (patch)
treece4c14e2b10cd30f710e84a228e29ceb51fc3a49 /src/node
parentfacdb8b331da17c10b122deb28f6d71d5797f063 (diff)
Replace pindex pointer with block reference
pindex can not be nullptr, so document that, and clear it up in the next commit.
Diffstat (limited to 'src/node')
-rw-r--r--src/node/blockstorage.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index d20c8391e8..aa7c805f92 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -722,14 +722,15 @@ static bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos, const CMessa
bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValidationState& state, CBlockIndex* pindex, const CChainParams& chainparams)
{
+ auto& block{*pindex};
AssertLockHeld(::cs_main);
// Write undo information to disk
- if (pindex->GetUndoPos().IsNull()) {
+ if (block.GetUndoPos().IsNull()) {
FlatFilePos _pos;
- if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo, CLIENT_VERSION) + 40)) {
+ if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo, CLIENT_VERSION) + 40)) {
return error("ConnectBlock(): FindUndoPos failed");
}
- if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), GetParams().MessageStart())) {
+ if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash(), GetParams().MessageStart())) {
return AbortNode(state, "Failed to write undo data");
}
// rev files are written in block height order, whereas blk files are written as blocks come in (often out of order)
@@ -737,14 +738,14 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
// in the block file info as below; note that this does not catch the case where the undo writes are keeping up
// with the block writes (usually when a synced up node is getting newly mined blocks) -- this case is caught in
// the FindBlockPos function
- if (_pos.nFile < m_last_blockfile && static_cast<uint32_t>(pindex->nHeight) == m_blockfile_info[_pos.nFile].nHeightLast) {
+ if (_pos.nFile < m_last_blockfile && static_cast<uint32_t>(block.nHeight) == m_blockfile_info[_pos.nFile].nHeightLast) {
FlushUndoFile(_pos.nFile, true);
}
// update nUndoPos in block index
- pindex->nUndoPos = _pos.nPos;
- pindex->nStatus |= BLOCK_HAVE_UNDO;
- m_dirty_blockindex.insert(pindex);
+ block.nUndoPos = _pos.nPos;
+ block.nStatus |= BLOCK_HAVE_UNDO;
+ m_dirty_blockindex.insert(&block);
}
return true;