mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge 8426e018bf into merged_master (Bitcoin PR bitcoin/bitcoin#30428)
This commit is contained in:
commit
84203ffb07
2 changed files with 12 additions and 18 deletions
|
|
@ -681,7 +681,7 @@ const CBlockIndex* BlockManager::GetLastCheckpoint(const CCheckpointData& data)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool BlockManager::IsBlockPruned(const CBlockIndex& block)
|
||||
bool BlockManager::IsBlockPruned(const CBlockIndex& block) const
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
return m_have_pruned && !(block.nStatus & BLOCK_HAVE_DATA) && (block.nTx > 0);
|
||||
|
|
@ -796,15 +796,10 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
|
|||
{
|
||||
const FlatFilePos pos{WITH_LOCK(::cs_main, return index.GetUndoPos())};
|
||||
|
||||
if (pos.IsNull()) {
|
||||
LogError("%s: no undo data available\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Open history file to read
|
||||
AutoFile filein{OpenUndoFile(pos, true)};
|
||||
if (filein.IsNull()) {
|
||||
LogError("%s: OpenUndoFile failed\n", __func__);
|
||||
LogError("%s: OpenUndoFile failed for %s\n", __func__, pos.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -816,13 +811,13 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
|
|||
verifier >> blockundo;
|
||||
filein >> hashChecksum;
|
||||
} catch (const std::exception& e) {
|
||||
LogError("%s: Deserialize or I/O error - %s\n", __func__, e.what());
|
||||
LogError("%s: Deserialize or I/O error - %s at %s\n", __func__, e.what(), pos.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify checksum
|
||||
if (hashChecksum != verifier.GetHash()) {
|
||||
LogError("%s: Checksum mismatch\n", __func__);
|
||||
LogError("%s: Checksum mismatch at %s\n", __func__, pos.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1079,7 +1074,7 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
|
|||
// Open history file to append
|
||||
AutoFile fileout{OpenBlockFile(pos)};
|
||||
if (fileout.IsNull()) {
|
||||
LogError("WriteBlockToDisk: OpenBlockFile failed\n");
|
||||
LogError("%s: OpenBlockFile failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1090,7 +1085,7 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
|
|||
// Write block
|
||||
long fileOutPos = ftell(fileout.Get());
|
||||
if (fileOutPos < 0) {
|
||||
LogError("WriteBlockToDisk: ftell failed\n");
|
||||
LogError("%s: ftell failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
pos.nPos = (unsigned int)fileOutPos;
|
||||
|
|
@ -1109,7 +1104,7 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
|
|||
if (block.GetUndoPos().IsNull()) {
|
||||
FlatFilePos _pos;
|
||||
if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo) + 40)) {
|
||||
LogError("ConnectBlock(): FindUndoPos failed\n");
|
||||
LogError("%s: FindUndoPos failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash())) {
|
||||
|
|
@ -1148,7 +1143,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
|
|||
// Open history file to read
|
||||
AutoFile filein{OpenBlockFile(pos, true)};
|
||||
if (filein.IsNull()) {
|
||||
LogError("ReadBlockFromDisk: OpenBlockFile failed for %s\n", pos.ToString());
|
||||
LogError("%s: OpenBlockFile failed for %s\n", __func__, pos.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1164,13 +1159,13 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
|
|||
const uint256 block_hash = block.GetHash();
|
||||
if (block_hash != GetConsensus().hashGenesisBlock &&
|
||||
!CheckProof(block, GetConsensus())) {
|
||||
LogError("ReadBlockFromDisk: Errors in block header at %s\n", pos.ToString());
|
||||
LogError("%s: Errors in block header at %s\n", __func__, pos.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Signet only: check block solution
|
||||
if (GetConsensus().signet_blocks && !CheckSignetBlockSolution(block, GetConsensus())) {
|
||||
LogError("ReadBlockFromDisk: Errors in block solution at %s\n", pos.ToString());
|
||||
LogError("%s: Errors in block solution at %s\n", __func__, pos.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1185,8 +1180,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const CBlockIndex& index) co
|
|||
return false;
|
||||
}
|
||||
if (block.GetHash() != index.GetBlockHash()) {
|
||||
LogError("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s\n",
|
||||
index.ToString(), block_pos.ToString());
|
||||
LogError("%s: GetHash() doesn't match index for %s at %s\n", __func__, index.ToString(), block_pos.ToString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue