mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge c9f288244b into merged_master (Bitcoin PR bitcoin/bitcoin#28483)
This commit is contained in:
commit
ace917697e
12 changed files with 66 additions and 84 deletions
|
|
@ -552,7 +552,7 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
|
|||
}
|
||||
for (std::set<int>::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++) {
|
||||
FlatFilePos pos(*it, 0);
|
||||
if (AutoFile{OpenBlockFile(pos, true)}.IsNull()) {
|
||||
if (OpenBlockFile(pos, true).IsNull()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -685,7 +685,7 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
|
|||
bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock) const
|
||||
{
|
||||
// Open history file to append
|
||||
AutoFile fileout{OpenUndoFile(pos)};
|
||||
CAutoFile fileout{OpenUndoFile(pos)};
|
||||
if (fileout.IsNull()) {
|
||||
return error("%s: OpenUndoFile failed", __func__);
|
||||
}
|
||||
|
|
@ -720,7 +720,7 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
|
|||
}
|
||||
|
||||
// Open history file to read
|
||||
AutoFile filein{OpenUndoFile(pos, true)};
|
||||
CAutoFile filein{OpenUndoFile(pos, true)};
|
||||
if (filein.IsNull()) {
|
||||
return error("%s: OpenUndoFile failed", __func__);
|
||||
}
|
||||
|
|
@ -808,15 +808,15 @@ FlatFileSeq BlockManager::UndoFileSeq() const
|
|||
return FlatFileSeq(m_opts.blocks_dir, "rev", UNDOFILE_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
FILE* BlockManager::OpenBlockFile(const FlatFilePos& pos, bool fReadOnly) const
|
||||
CAutoFile BlockManager::OpenBlockFile(const FlatFilePos& pos, bool fReadOnly) const
|
||||
{
|
||||
return BlockFileSeq().Open(pos, fReadOnly);
|
||||
return CAutoFile{BlockFileSeq().Open(pos, fReadOnly), CLIENT_VERSION};
|
||||
}
|
||||
|
||||
/** Open an undo file (rev?????.dat) */
|
||||
FILE* BlockManager::OpenUndoFile(const FlatFilePos& pos, bool fReadOnly) const
|
||||
CAutoFile BlockManager::OpenUndoFile(const FlatFilePos& pos, bool fReadOnly) const
|
||||
{
|
||||
return UndoFileSeq().Open(pos, fReadOnly);
|
||||
return CAutoFile{UndoFileSeq().Open(pos, fReadOnly), CLIENT_VERSION};
|
||||
}
|
||||
|
||||
fs::path BlockManager::GetBlockPosFilename(const FlatFilePos& pos) const
|
||||
|
|
@ -917,7 +917,7 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
|
|||
bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
|
||||
{
|
||||
// Open history file to append
|
||||
CAutoFile fileout{OpenBlockFile(pos), CLIENT_VERSION};
|
||||
CAutoFile fileout{OpenBlockFile(pos)};
|
||||
if (fileout.IsNull()) {
|
||||
return error("WriteBlockToDisk: OpenBlockFile failed");
|
||||
}
|
||||
|
|
@ -972,7 +972,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
|
|||
block.SetNull();
|
||||
|
||||
// Open history file to read
|
||||
CAutoFile filein{OpenBlockFile(pos, true), CLIENT_VERSION};
|
||||
CAutoFile filein{OpenBlockFile(pos, true)};
|
||||
if (filein.IsNull()) {
|
||||
return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
|
||||
}
|
||||
|
|
@ -1018,7 +1018,7 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
|
|||
{
|
||||
FlatFilePos hpos = pos;
|
||||
hpos.nPos -= 8; // Seek back 8 bytes for meta header
|
||||
AutoFile filein{OpenBlockFile(hpos, true)};
|
||||
CAutoFile filein{OpenBlockFile(hpos, true)};
|
||||
if (filein.IsNull()) {
|
||||
return error("%s: OpenBlockFile failed for %s", __func__, pos.ToString());
|
||||
}
|
||||
|
|
@ -1110,8 +1110,8 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
|||
if (!fs::exists(chainman.m_blockman.GetBlockPosFilename(pos))) {
|
||||
break; // No block files left to reindex
|
||||
}
|
||||
FILE* file = chainman.m_blockman.OpenBlockFile(pos, true);
|
||||
if (!file) {
|
||||
CAutoFile file{chainman.m_blockman.OpenBlockFile(pos, true)};
|
||||
if (file.IsNull()) {
|
||||
break; // This error is logged in OpenBlockFile
|
||||
}
|
||||
LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile);
|
||||
|
|
@ -1131,8 +1131,8 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
|||
|
||||
// -loadblock=
|
||||
for (const fs::path& path : vImportFiles) {
|
||||
FILE* file = fsbridge::fopen(path, "rb");
|
||||
if (file) {
|
||||
CAutoFile file{fsbridge::fopen(path, "rb"), CLIENT_VERSION};
|
||||
if (!file.IsNull()) {
|
||||
LogPrintf("Importing blocks file %s...\n", fs::PathToString(path));
|
||||
chainman.LoadExternalBlockFile(file);
|
||||
if (chainman.m_interrupt) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue