From fa389d902fbf5fac19fba8c5d0c5e0a25f15ca63 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 4 Jul 2023 18:59:49 +0200 Subject: refactor: Drop unused fclose() from BufferedFile This was only explicitly used in the tests, where it can be replaced by wrapping the original raw file pointer into a CAutoFile on creation and then calling CAutoFile::fclose(). Also, it was used in LoadExternalBlockFile(), where it can also be replaced by the (implicit call to the) CAutoFile destructor after wrapping the original raw file pointer in a CAutoFile. --- src/validation.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/validation.cpp') diff --git a/src/validation.cpp b/src/validation.cpp index 1d4786bb17..090fa34a93 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4589,7 +4589,6 @@ void ChainstateManager::LoadExternalBlockFile( int nLoaded = 0; try { - // This takes over fileIn and calls fclose() on it in the BufferedFile destructor BufferedFile blkdat{fileIn, 2 * MAX_BLOCK_SERIALIZED_SIZE, MAX_BLOCK_SERIALIZED_SIZE + 8, CLIENT_VERSION}; // nRewind indicates where to resume scanning in case something goes wrong, // such as a block fails to deserialize. -- cgit v1.2.3 From 9999b89cd37fb2a23c5ebcd91d9cb31d69375933 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 4 Jul 2023 17:09:13 +0200 Subject: Make BufferedFile to be a CAutoFile wrapper This refactor allows to forward some calls to the underlying CAutoFile, instead of re-implementing the logic in the buffered file. --- src/validation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/validation.cpp') diff --git a/src/validation.cpp b/src/validation.cpp index 090fa34a93..1c9806ded7 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4577,7 +4577,7 @@ bool Chainstate::LoadGenesisBlock() } void ChainstateManager::LoadExternalBlockFile( - FILE* fileIn, + CAutoFile& file_in, FlatFilePos* dbp, std::multimap* blocks_with_unknown_parent) { @@ -4589,7 +4589,7 @@ void ChainstateManager::LoadExternalBlockFile( int nLoaded = 0; try { - BufferedFile blkdat{fileIn, 2 * MAX_BLOCK_SERIALIZED_SIZE, MAX_BLOCK_SERIALIZED_SIZE + 8, CLIENT_VERSION}; + BufferedFile blkdat{file_in, 2 * MAX_BLOCK_SERIALIZED_SIZE, MAX_BLOCK_SERIALIZED_SIZE + 8}; // nRewind indicates where to resume scanning in case something goes wrong, // such as a block fails to deserialize. uint64_t nRewind = blkdat.GetPos(); -- cgit v1.2.3