Merge bitcoin/bitcoin#30927: Follow-up after AutoFile position caching: remove unused code
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled

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-ACK caac06f784
  theStack:
    Code-review ACK caac06f784
  l0rinc:
    ACK caac06f784
  tdb3:
    CR ACK caac06f784

Tree-SHA512: 297791f093e0142730f815c11dd3466b98f7e7edea86094a815dae989ef40d8056db10e0fed6e575d530903c18e80c08d36d3f1e6b828f2d955528f365b22008
This commit is contained in:
merge-script 2024-09-19 16:43:46 +01:00
commit 84cd6478c4
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
4 changed files with 9 additions and 19 deletions

View file

@ -684,10 +684,6 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
// Write undo data
long fileOutPos = fileout.tell();
if (fileOutPos < 0) {
LogError("%s: ftell failed\n", __func__);
return false;
}
pos.nPos = (unsigned int)fileOutPos;
fileout << blockundo;
@ -982,10 +978,6 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
// Write block
long fileOutPos = fileout.tell();
if (fileOutPos < 0) {
LogError("%s: ftell failed\n", __func__);
return false;
}
pos.nPos = (unsigned int)fileOutPos;
fileout << TX_WITH_WITNESS(block);

View file

@ -77,8 +77,6 @@ std::optional<uint256> ReadSnapshotBaseBlockhash(fs::path chaindir)
afile.seek(0, SEEK_END);
if (position != afile.tell()) {
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;
}

View file

@ -106,11 +106,6 @@ bool AutoFile::Commit()
return ::FileCommit(m_file);
}
bool AutoFile::IsError()
{
return ferror(m_file);
}
bool AutoFile::Truncate(unsigned size)
{
return ::TruncateFile(m_file, size);

View file

@ -430,9 +430,18 @@ public:
/** Implementation detail, only used internally. */
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);
/** Find position within the file. Will throw if unknown. */
int64_t tell();
/** Wrapper around FileCommit(). */
bool Commit();
/** Wrapper around TruncateFile(). */
bool Truncate(unsigned size);
//
// Stream subset
//
@ -453,10 +462,6 @@ public:
::Unserialize(*this, obj);
return *this;
}
bool Commit();
bool IsError();
bool Truncate(unsigned size);
};
/** Wrapper around an AutoFile& that implements a ring buffer to