mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge bitcoin/bitcoin#30927: Follow-up after AutoFile position caching: remove unused code
Some checks failed
Some checks failed
caac06f784
streams: reorder/document functions (Pieter Wuille)67a3d59076
streams: remove unused code (Pieter Wuille) Pull request description: This is a follow-up to #30884. Remove a number of dead code paths, and improve the code organization and documentation, in `AutoFile`. ACKs for top commit: maflcko: re-ACKcaac06f784
theStack: Code-review ACKcaac06f784
l0rinc: ACKcaac06f784
tdb3: CR ACKcaac06f784
Tree-SHA512: 297791f093e0142730f815c11dd3466b98f7e7edea86094a815dae989ef40d8056db10e0fed6e575d530903c18e80c08d36d3f1e6b828f2d955528f365b22008
This commit is contained in:
commit
84cd6478c4
4 changed files with 9 additions and 19 deletions
|
@ -684,10 +684,6 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
|
||||||
|
|
||||||
// Write undo data
|
// Write undo data
|
||||||
long fileOutPos = fileout.tell();
|
long fileOutPos = fileout.tell();
|
||||||
if (fileOutPos < 0) {
|
|
||||||
LogError("%s: ftell failed\n", __func__);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pos.nPos = (unsigned int)fileOutPos;
|
pos.nPos = (unsigned int)fileOutPos;
|
||||||
fileout << blockundo;
|
fileout << blockundo;
|
||||||
|
|
||||||
|
@ -982,10 +978,6 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
|
||||||
|
|
||||||
// Write block
|
// Write block
|
||||||
long fileOutPos = fileout.tell();
|
long fileOutPos = fileout.tell();
|
||||||
if (fileOutPos < 0) {
|
|
||||||
LogError("%s: ftell failed\n", __func__);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pos.nPos = (unsigned int)fileOutPos;
|
pos.nPos = (unsigned int)fileOutPos;
|
||||||
fileout << TX_WITH_WITNESS(block);
|
fileout << TX_WITH_WITNESS(block);
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,6 @@ std::optional<uint256> ReadSnapshotBaseBlockhash(fs::path chaindir)
|
||||||
afile.seek(0, SEEK_END);
|
afile.seek(0, SEEK_END);
|
||||||
if (position != afile.tell()) {
|
if (position != afile.tell()) {
|
||||||
LogPrintf("[snapshot] warning: unexpected trailing data in %s\n", read_from_str);
|
LogPrintf("[snapshot] warning: unexpected trailing data in %s\n", read_from_str);
|
||||||
} else if (afile.IsError()) {
|
|
||||||
LogPrintf("[snapshot] warning: i/o error reading %s\n", read_from_str);
|
|
||||||
}
|
}
|
||||||
return base_blockhash;
|
return base_blockhash;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,11 +106,6 @@ bool AutoFile::Commit()
|
||||||
return ::FileCommit(m_file);
|
return ::FileCommit(m_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoFile::IsError()
|
|
||||||
{
|
|
||||||
return ferror(m_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AutoFile::Truncate(unsigned size)
|
bool AutoFile::Truncate(unsigned size)
|
||||||
{
|
{
|
||||||
return ::TruncateFile(m_file, size);
|
return ::TruncateFile(m_file, size);
|
||||||
|
|
|
@ -430,9 +430,18 @@ public:
|
||||||
/** Implementation detail, only used internally. */
|
/** Implementation detail, only used internally. */
|
||||||
std::size_t detail_fread(Span<std::byte> dst);
|
std::size_t detail_fread(Span<std::byte> dst);
|
||||||
|
|
||||||
|
/** Wrapper around fseek(). Will throw if seeking is not possible. */
|
||||||
void seek(int64_t offset, int origin);
|
void seek(int64_t offset, int origin);
|
||||||
|
|
||||||
|
/** Find position within the file. Will throw if unknown. */
|
||||||
int64_t tell();
|
int64_t tell();
|
||||||
|
|
||||||
|
/** Wrapper around FileCommit(). */
|
||||||
|
bool Commit();
|
||||||
|
|
||||||
|
/** Wrapper around TruncateFile(). */
|
||||||
|
bool Truncate(unsigned size);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Stream subset
|
// Stream subset
|
||||||
//
|
//
|
||||||
|
@ -453,10 +462,6 @@ public:
|
||||||
::Unserialize(*this, obj);
|
::Unserialize(*this, obj);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Commit();
|
|
||||||
bool IsError();
|
|
||||||
bool Truncate(unsigned size);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Wrapper around an AutoFile& that implements a ring buffer to
|
/** Wrapper around an AutoFile& that implements a ring buffer to
|
||||||
|
|
Loading…
Add table
Reference in a new issue