mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
Merge 5d6f6fd00d into merged_master (Bitcoin PR bitcoin/bitcoin#31490)
This commit is contained in:
commit
bde05e1016
21 changed files with 181 additions and 206 deletions
|
|
@ -2588,7 +2588,7 @@ DisconnectResult Chainstate::DisconnectBlock(const CBlock& block, const CBlockIn
|
|||
bool fClean = true;
|
||||
|
||||
CBlockUndo blockUndo;
|
||||
if (!m_blockman.UndoReadFromDisk(blockUndo, *pindex)) {
|
||||
if (!m_blockman.ReadBlockUndo(blockUndo, *pindex)) {
|
||||
LogError("DisconnectBlock(): failure reading undo data\n");
|
||||
return DISCONNECT_FAILED;
|
||||
}
|
||||
|
|
@ -3141,7 +3141,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!m_blockman.WriteUndoDataForBlock(blockundo, state, *pindex)) {
|
||||
if (!m_blockman.WriteBlockUndo(blockundo, state, *pindex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -3530,7 +3530,7 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
|
|||
// Read block from disk.
|
||||
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
||||
CBlock& block = *pblock;
|
||||
if (!m_blockman.ReadBlockFromDisk(block, *pindexDelete)) {
|
||||
if (!m_blockman.ReadBlock(block, *pindexDelete)) {
|
||||
LogError("DisconnectTip(): Failed to read block\n");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3641,7 +3641,7 @@ bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew,
|
|||
std::shared_ptr<const CBlock> pthisBlock;
|
||||
if (!pblock) {
|
||||
std::shared_ptr<CBlock> pblockNew = std::make_shared<CBlock>();
|
||||
if (!m_blockman.ReadBlockFromDisk(*pblockNew, *pindexNew)) {
|
||||
if (!m_blockman.ReadBlock(*pblockNew, *pindexNew)) {
|
||||
return FatalError(m_chainman.GetNotifications(), state, _("Failed to read block."));
|
||||
}
|
||||
pthisBlock = pblockNew;
|
||||
|
|
@ -5198,7 +5198,7 @@ bool ChainstateManager::AcceptBlock(const std::shared_ptr<const CBlock>& pblock,
|
|||
blockPos = *dbp;
|
||||
m_blockman.UpdateBlockInfo(block, pindex->nHeight, blockPos);
|
||||
} else {
|
||||
blockPos = m_blockman.SaveBlockToDisk(block, pindex->nHeight);
|
||||
blockPos = m_blockman.WriteBlock(block, pindex->nHeight);
|
||||
if (blockPos.IsNull()) {
|
||||
state.Error(strprintf("%s: Failed to find position to write new block to disk", __func__));
|
||||
return false;
|
||||
|
|
@ -5431,8 +5431,8 @@ VerifyDBResult CVerifyDB::VerifyDB(
|
|||
}
|
||||
CBlock block;
|
||||
// check level 0: read from disk
|
||||
if (!chainstate.m_blockman.ReadBlockFromDisk(block, *pindex)) {
|
||||
LogPrintf("Verification error: ReadBlockFromDisk failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
if (!chainstate.m_blockman.ReadBlock(block, *pindex)) {
|
||||
LogPrintf("Verification error: ReadBlock failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
return VerifyDBResult::CORRUPTED_BLOCK_DB;
|
||||
}
|
||||
// check level 1: verify block validity
|
||||
|
|
@ -5445,7 +5445,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
|
|||
if (nCheckLevel >= 2 && pindex) {
|
||||
CBlockUndo undo;
|
||||
if (!pindex->GetUndoPos().IsNull()) {
|
||||
if (!chainstate.m_blockman.UndoReadFromDisk(undo, *pindex)) {
|
||||
if (!chainstate.m_blockman.ReadBlockUndo(undo, *pindex)) {
|
||||
LogPrintf("Verification error: found bad undo data at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
return VerifyDBResult::CORRUPTED_BLOCK_DB;
|
||||
}
|
||||
|
|
@ -5497,8 +5497,8 @@ VerifyDBResult CVerifyDB::VerifyDB(
|
|||
m_notifications.progress(_("Verifying blocks…"), percentageDone, false);
|
||||
pindex = chainstate.m_chain.Next(pindex);
|
||||
CBlock block;
|
||||
if (!chainstate.m_blockman.ReadBlockFromDisk(block, *pindex)) {
|
||||
LogPrintf("Verification error: ReadBlockFromDisk failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
if (!chainstate.m_blockman.ReadBlock(block, *pindex)) {
|
||||
LogPrintf("Verification error: ReadBlock failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
return VerifyDBResult::CORRUPTED_BLOCK_DB;
|
||||
}
|
||||
if (!chainstate.ConnectBlock(block, state, pindex, coins, nullptr)) {
|
||||
|
|
@ -5526,8 +5526,8 @@ bool Chainstate::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& in
|
|||
AssertLockHeld(cs_main);
|
||||
// TODO: merge with ConnectBlock
|
||||
CBlock block;
|
||||
if (!m_blockman.ReadBlockFromDisk(block, *pindex)) {
|
||||
LogError("ReplayBlock(): ReadBlockFromDisk failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
if (!m_blockman.ReadBlock(block, *pindex)) {
|
||||
LogError("ReplayBlock(): ReadBlock failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -5584,8 +5584,8 @@ bool Chainstate::ReplayBlocks()
|
|||
while (pindexOld != pindexFork) {
|
||||
if (pindexOld->nHeight > 0) { // Never disconnect the genesis block.
|
||||
CBlock block;
|
||||
if (!m_blockman.ReadBlockFromDisk(block, *pindexOld)) {
|
||||
LogError("RollbackBlock(): ReadBlockFromDisk() failed at %d, hash=%s\n", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
|
||||
if (!m_blockman.ReadBlock(block, *pindexOld)) {
|
||||
LogError("RollbackBlock(): ReadBlock() failed at %d, hash=%s\n", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
|
||||
return false;
|
||||
}
|
||||
LogPrintf("Rolling back %s (%i)\n", pindexOld->GetBlockHash().ToString(), pindexOld->nHeight);
|
||||
|
|
@ -5696,7 +5696,7 @@ bool Chainstate::LoadGenesisBlock()
|
|||
|
||||
try {
|
||||
const CBlock& block = params.GenesisBlock();
|
||||
FlatFilePos blockPos{m_blockman.SaveBlockToDisk(block, 0)};
|
||||
FlatFilePos blockPos{m_blockman.WriteBlock(block, 0)};
|
||||
if (blockPos.IsNull()) {
|
||||
LogError("%s: writing genesis block to disk failed\n", __func__);
|
||||
return false;
|
||||
|
|
@ -5853,7 +5853,7 @@ void ChainstateManager::LoadExternalBlockFile(
|
|||
while (range.first != range.second) {
|
||||
std::multimap<uint256, FlatFilePos>::iterator it = range.first;
|
||||
std::shared_ptr<CBlock> pblockrecursive = std::make_shared<CBlock>();
|
||||
if (m_blockman.ReadBlockFromDisk(*pblockrecursive, it->second)) {
|
||||
if (m_blockman.ReadBlock(*pblockrecursive, it->second)) {
|
||||
LogDebug(BCLog::REINDEX, "%s: Processing out of order child %s of %s\n", __func__, pblockrecursive->GetHash().ToString(),
|
||||
head.ToString());
|
||||
LOCK(cs_main);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue