@@ -269,9 +269,9 @@ CBlockIndex* BlockManager::InsertBlockIndex(const uint256& hash)
269269 return pindex;
270270}
271271
272- bool BlockManager::LoadBlockIndex (const Consensus::Params& consensus_params )
272+ bool BlockManager::LoadBlockIndex ()
273273{
274- if (!m_block_tree_db->LoadBlockIndexGuts (consensus_params , [this ](const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED (cs_main) { return this ->InsertBlockIndex (hash); })) {
274+ if (!m_block_tree_db->LoadBlockIndexGuts (GetConsensus () , [this ](const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED (cs_main) { return this ->InsertBlockIndex (hash); })) {
275275 return false ;
276276 }
277277
@@ -348,7 +348,7 @@ bool BlockManager::WriteBlockIndexDB()
348348
349349bool BlockManager::LoadBlockIndexDB ()
350350{
351- if (!LoadBlockIndex (:: Params (). GetConsensus () )) {
351+ if (!LoadBlockIndex ()) {
352352 return false ;
353353 }
354354
@@ -726,31 +726,31 @@ static bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos, const CMessa
726726 return true ;
727727}
728728
729- bool BlockManager::WriteUndoDataForBlock (const CBlockUndo& blockundo, BlockValidationState& state, CBlockIndex* pindex, const CChainParams& chainparams )
729+ bool BlockManager::WriteUndoDataForBlock (const CBlockUndo& blockundo, BlockValidationState& state, CBlockIndex& block )
730730{
731731 AssertLockHeld (::cs_main);
732732 // Write undo information to disk
733- if (pindex-> GetUndoPos ().IsNull ()) {
733+ if (block. GetUndoPos ().IsNull ()) {
734734 FlatFilePos _pos;
735- if (!FindUndoPos (state, pindex-> nFile , _pos, ::GetSerializeSize (blockundo, CLIENT_VERSION ) + 40 )) {
735+ if (!FindUndoPos (state, block. nFile , _pos, ::GetSerializeSize (blockundo, CLIENT_VERSION ) + 40 )) {
736736 return error (" ConnectBlock(): FindUndoPos failed" );
737737 }
738- if (!UndoWriteToDisk (blockundo, _pos, pindex-> pprev ->GetBlockHash (), chainparams .MessageStart ())) {
738+ if (!UndoWriteToDisk (blockundo, _pos, block. pprev ->GetBlockHash (), GetParams () .MessageStart ())) {
739739 return AbortNode (state, " Failed to write undo data" );
740740 }
741741 // rev files are written in block height order, whereas blk files are written as blocks come in (often out of order)
742742 // we want to flush the rev (undo) file once we've written the last block, which is indicated by the last height
743743 // in the block file info as below; note that this does not catch the case where the undo writes are keeping up
744744 // with the block writes (usually when a synced up node is getting newly mined blocks) -- this case is caught in
745745 // the FindBlockPos function
746- if (_pos.nFile < m_last_blockfile && static_cast <uint32_t >(pindex-> nHeight ) == m_blockfile_info[_pos.nFile ].nHeightLast ) {
746+ if (_pos.nFile < m_last_blockfile && static_cast <uint32_t >(block. nHeight ) == m_blockfile_info[_pos.nFile ].nHeightLast ) {
747747 FlushUndoFile (_pos.nFile , true );
748748 }
749749
750750 // update nUndoPos in block index
751- pindex-> nUndoPos = _pos.nPos ;
752- pindex-> nStatus |= BLOCK_HAVE_UNDO ;
753- m_dirty_blockindex.insert (pindex );
751+ block. nUndoPos = _pos.nPos ;
752+ block. nStatus |= BLOCK_HAVE_UNDO ;
753+ m_dirty_blockindex.insert (&block );
754754 }
755755
756756 return true ;
@@ -795,7 +795,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus
795795 return true ;
796796}
797797
798- FlatFilePos BlockManager::SaveBlockToDisk (const CBlock& block, int nHeight, CChain& active_chain, const CChainParams& chainparams, const FlatFilePos* dbp)
798+ FlatFilePos BlockManager::SaveBlockToDisk (const CBlock& block, int nHeight, CChain& active_chain, const FlatFilePos* dbp)
799799{
800800 unsigned int nBlockSize = ::GetSerializeSize (block, CLIENT_VERSION );
801801 FlatFilePos blockPos;
@@ -813,7 +813,7 @@ FlatFilePos BlockManager::SaveBlockToDisk(const CBlock& block, int nHeight, CCha
813813 return FlatFilePos ();
814814 }
815815 if (!position_known) {
816- if (!WriteBlockToDisk (block, blockPos, chainparams .MessageStart ())) {
816+ if (!WriteBlockToDisk (block, blockPos, GetParams () .MessageStart ())) {
817817 AbortNode (" Failed to write block" );
818818 return FlatFilePos ();
819819 }
0 commit comments