mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
scripted-diff: rename block and undo functions for consistency
Co-authored-by: Ryan Ofsky <ryan@ofsky.org> Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com> -BEGIN VERIFY SCRIPT- grep -r -wE 'WriteBlock|ReadRawBlock|ReadBlock|WriteBlockUndo|ReadBlockUndo' $(git ls-files src/ ':!src/leveldb') && \ echo "Error: One or more target names already exist!" && exit 1 sed -i \ -e 's/\bSaveBlockToDisk/WriteBlock/g' \ -e 's/\bReadRawBlockFromDisk/ReadRawBlock/g' \ -e 's/\bReadBlockFromDisk/ReadBlock/g' \ -e 's/\bWriteUndoDataForBlock/WriteBlockUndo/g' \ -e 's/\bUndoReadFromDisk/ReadBlockUndo/g' \ $(git ls-files src/ ':!src/leveldb') -END VERIFY SCRIPT-
This commit is contained in:
@@ -2301,7 +2301,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;
|
||||
}
|
||||
@@ -2747,7 +2747,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;
|
||||
}
|
||||
|
||||
@@ -3068,7 +3068,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;
|
||||
}
|
||||
@@ -3179,7 +3179,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;
|
||||
@@ -4564,7 +4564,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;
|
||||
@@ -4797,8 +4797,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
|
||||
@@ -4811,7 +4811,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;
|
||||
}
|
||||
@@ -4863,8 +4863,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)) {
|
||||
@@ -4892,8 +4892,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;
|
||||
}
|
||||
|
||||
@@ -4950,8 +4950,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);
|
||||
@@ -5062,7 +5062,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;
|
||||
@@ -5219,7 +5219,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);
|
||||
|
||||
Reference in New Issue
Block a user