Skip to content

Commit 84cd647

Browse files
committed
Merge bitcoin/bitcoin#30927: Follow-up after AutoFile position caching: remove unused code
caac06f streams: reorder/document functions (Pieter Wuille) 67a3d59 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 caac06f theStack: Code-review ACK caac06f l0rinc: ACK caac06f tdb3: CR ACK caac06f Tree-SHA512: 297791f093e0142730f815c11dd3466b98f7e7edea86094a815dae989ef40d8056db10e0fed6e575d530903c18e80c08d36d3f1e6b828f2d955528f365b22008
2 parents 2db926f + caac06f commit 84cd647

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

src/node/blockstorage.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,6 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
684684

685685
// Write undo data
686686
long fileOutPos = fileout.tell();
687-
if (fileOutPos < 0) {
688-
LogError("%s: ftell failed\n", __func__);
689-
return false;
690-
}
691687
pos.nPos = (unsigned int)fileOutPos;
692688
fileout << blockundo;
693689

@@ -982,10 +978,6 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
982978

983979
// Write block
984980
long fileOutPos = fileout.tell();
985-
if (fileOutPos < 0) {
986-
LogError("%s: ftell failed\n", __func__);
987-
return false;
988-
}
989981
pos.nPos = (unsigned int)fileOutPos;
990982
fileout << TX_WITH_WITNESS(block);
991983

src/node/utxo_snapshot.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ std::optional<uint256> ReadSnapshotBaseBlockhash(fs::path chaindir)
7777
afile.seek(0, SEEK_END);
7878
if (position != afile.tell()) {
7979
LogPrintf("[snapshot] warning: unexpected trailing data in %s\n", read_from_str);
80-
} else if (afile.IsError()) {
81-
LogPrintf("[snapshot] warning: i/o error reading %s\n", read_from_str);
8280
}
8381
return base_blockhash;
8482
}

src/streams.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ bool AutoFile::Commit()
106106
return ::FileCommit(m_file);
107107
}
108108

109-
bool AutoFile::IsError()
110-
{
111-
return ferror(m_file);
112-
}
113-
114109
bool AutoFile::Truncate(unsigned size)
115110
{
116111
return ::TruncateFile(m_file, size);

src/streams.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,18 @@ class AutoFile
430430
/** Implementation detail, only used internally. */
431431
std::size_t detail_fread(Span<std::byte> dst);
432432

433+
/** Wrapper around fseek(). Will throw if seeking is not possible. */
433434
void seek(int64_t offset, int origin);
435+
436+
/** Find position within the file. Will throw if unknown. */
434437
int64_t tell();
435438

439+
/** Wrapper around FileCommit(). */
440+
bool Commit();
441+
442+
/** Wrapper around TruncateFile(). */
443+
bool Truncate(unsigned size);
444+
436445
//
437446
// Stream subset
438447
//
@@ -453,10 +462,6 @@ class AutoFile
453462
::Unserialize(*this, obj);
454463
return *this;
455464
}
456-
457-
bool Commit();
458-
bool IsError();
459-
bool Truncate(unsigned size);
460465
};
461466

462467
/** Wrapper around an AutoFile& that implements a ring buffer to

0 commit comments

Comments
 (0)