mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Reload trimmed header from index instead of block, block may have been pruned
This commit is contained in:
parent
afc16e8f84
commit
4259278ff5
8 changed files with 70 additions and 44 deletions
|
|
@ -803,23 +803,6 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ReadBlockHeaderFromDisk(CBlockHeader& header, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
|
||||
{
|
||||
// Not very efficient: read a block and throw away all but the header.
|
||||
CBlock tmp;
|
||||
if (!ReadBlockFromDisk(tmp, pindex, consensusParams)) {
|
||||
return false;
|
||||
}
|
||||
const FlatFilePos block_pos{WITH_LOCK(cs_main, return pindex->GetBlockPos())};
|
||||
|
||||
header = tmp.GetBlockHeader();
|
||||
if (tmp.GetHash() != pindex->GetBlockHash()) {
|
||||
return error("ReadBlockheaderFromDisk(CBlockHeader&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
|
||||
pindex->ToString(), block_pos.ToString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos, const CMessageHeader::MessageStartChars& message_start)
|
||||
{
|
||||
FlatFilePos hpos = pos;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue