mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
Move functions to BlockManager
Needed for a later commit
This commit is contained in:
@@ -2135,7 +2135,7 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
||||
if (fJustCheck)
|
||||
return true;
|
||||
|
||||
if (!WriteUndoDataForBlock(blockundo, state, pindex, m_params)) {
|
||||
if (!m_blockman.WriteUndoDataForBlock(blockundo, state, pindex, m_params)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2269,7 +2269,7 @@ bool CChainState::FlushStateToDisk(
|
||||
LOG_TIME_MILLIS_WITH_CATEGORY("write block and undo data to disk", BCLog::BENCH);
|
||||
|
||||
// First make sure all block and undo data is flushed to disk.
|
||||
FlushBlockFile();
|
||||
m_blockman.FlushBlockFile();
|
||||
}
|
||||
|
||||
// Then update all block file information (which may refer to block and undo files).
|
||||
@@ -3604,7 +3604,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, Block
|
||||
// Write block to history file
|
||||
if (fNewBlock) *fNewBlock = true;
|
||||
try {
|
||||
FlatFilePos blockPos = SaveBlockToDisk(block, pindex->nHeight, m_chain, m_params, dbp);
|
||||
FlatFilePos blockPos{m_blockman.SaveBlockToDisk(block, pindex->nHeight, m_chain, m_params, dbp)};
|
||||
if (blockPos.IsNull()) {
|
||||
state.Error(strprintf("%s: Failed to find position to write new block to disk", __func__));
|
||||
return false;
|
||||
@@ -4039,9 +4039,10 @@ bool CChainState::LoadGenesisBlock()
|
||||
|
||||
try {
|
||||
const CBlock& block = m_params.GenesisBlock();
|
||||
FlatFilePos blockPos = SaveBlockToDisk(block, 0, m_chain, m_params, nullptr);
|
||||
if (blockPos.IsNull())
|
||||
FlatFilePos blockPos{m_blockman.SaveBlockToDisk(block, 0, m_chain, m_params, nullptr)};
|
||||
if (blockPos.IsNull()) {
|
||||
return error("%s: writing genesis block to disk failed", __func__);
|
||||
}
|
||||
CBlockIndex *pindex = m_blockman.AddToBlockIndex(block);
|
||||
ReceivedBlockTransactions(block, pindex, blockPos);
|
||||
} catch (const std::runtime_error& e) {
|
||||
|
||||
Reference in New Issue
Block a user