mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-10 17:02:03 +02:00
Merge bitcoin/bitcoin#30927: Follow-up after AutoFile position caching: remove unused code
caac06f784c5d94c6a5f7d0b586f9ddbbe55c369 streams: reorder/document functions (Pieter Wuille) 67a3d590768301fb46a93fdb0a5c66c0c2de1082 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 caac06f784c5d94c6a5f7d0b586f9ddbbe55c369 theStack: Code-review ACK caac06f784c5d94c6a5f7d0b586f9ddbbe55c369 l0rinc: ACK caac06f784c5d94c6a5f7d0b586f9ddbbe55c369 tdb3: CR ACK caac06f784c5d94c6a5f7d0b586f9ddbbe55c369 Tree-SHA512: 297791f093e0142730f815c11dd3466b98f7e7edea86094a815dae989ef40d8056db10e0fed6e575d530903c18e80c08d36d3f1e6b828f2d955528f365b22008
This commit is contained in:
commit
84cd6478c4
@ -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…
x
Reference in New Issue
Block a user