mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 02:02:42 +02:00
Merge bitcoin/bitcoin#25285: Add AutoFile without ser-type and ser-version and use it where possible
facc2fa7b8Use AutoFile where possible (MacroFake)6666803c89streams: Add AutoFile without ser-type and ser-version (MacroFake) Pull request description: This was done in the context of https://github.com/bitcoin/bitcoin/pull/25284 , but I think it also makes sense standalone. The basic idea is that serialization type should not be initialized when it is not needed. Same for the serialization version. So do this here for `AutoFile`. `CAutoFile` remains in places where it is not yet possible. ACKs for top commit: laanwj: Code review ACKfacc2fa7b8fanquake: ACKfacc2fa7b8Tree-SHA512: d82d024d55af57565ac53d9d1517afafc12b46964effba0332de62a6c77869356fa77f89e6d4834438fff44c45b64fccdf5a1358bfea03e28dfe55013b3c099d
This commit is contained in:
@@ -133,7 +133,7 @@ bool BlockFilterIndex::CustomCommit(CDBBatch& batch)
|
||||
const FlatFilePos& pos = m_next_filter_pos;
|
||||
|
||||
// Flush current filter file to disk.
|
||||
CAutoFile file(m_filter_fileseq->Open(pos), SER_DISK, CLIENT_VERSION);
|
||||
AutoFile file{m_filter_fileseq->Open(pos)};
|
||||
if (file.IsNull()) {
|
||||
return error("%s: Failed to open filter file %d", __func__, pos.nFile);
|
||||
}
|
||||
@@ -147,7 +147,7 @@ bool BlockFilterIndex::CustomCommit(CDBBatch& batch)
|
||||
|
||||
bool BlockFilterIndex::ReadFilterFromDisk(const FlatFilePos& pos, const uint256& hash, BlockFilter& filter) const
|
||||
{
|
||||
CAutoFile filein(m_filter_fileseq->Open(pos, true), SER_DISK, CLIENT_VERSION);
|
||||
AutoFile filein{m_filter_fileseq->Open(pos, true)};
|
||||
if (filein.IsNull()) {
|
||||
return false;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ size_t BlockFilterIndex::WriteFilterToDisk(FlatFilePos& pos, const BlockFilter&
|
||||
|
||||
// If writing the filter would overflow the file, flush and move to the next one.
|
||||
if (pos.nPos + data_size > MAX_FLTR_FILE_SIZE) {
|
||||
CAutoFile last_file(m_filter_fileseq->Open(pos), SER_DISK, CLIENT_VERSION);
|
||||
AutoFile last_file{m_filter_fileseq->Open(pos)};
|
||||
if (last_file.IsNull()) {
|
||||
LogPrintf("%s: Failed to open filter file %d\n", __func__, pos.nFile);
|
||||
return 0;
|
||||
@@ -205,7 +205,7 @@ size_t BlockFilterIndex::WriteFilterToDisk(FlatFilePos& pos, const BlockFilter&
|
||||
return 0;
|
||||
}
|
||||
|
||||
CAutoFile fileout(m_filter_fileseq->Open(pos), SER_DISK, CLIENT_VERSION);
|
||||
AutoFile fileout{m_filter_fileseq->Open(pos)};
|
||||
if (fileout.IsNull()) {
|
||||
LogPrintf("%s: Failed to open filter file %d\n", __func__, pos.nFile);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user