aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-09-12 12:23:49 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-09-12 12:55:29 +0200
commitfa19c914f7fe7be127c0fb330b41ff7c091f40aa (patch)
treef399ed252fb304ee48556cef85e860deb4ca1ffb /src
parentfa2f2413b87f5fc1e5c92bf510beebdcd0091714 (diff)
scripted-diff: Rename CBufferedFile to BufferedFile
While touching all constructors in the previous commit, the class name can be adjusted to comply with the style guide. -BEGIN VERIFY SCRIPT- sed -i 's/CBufferedFile/BufferedFile/g' $( git grep -l CBufferedFile ) -END VERIFY SCRIPT-
Diffstat (limited to 'src')
-rw-r--r--src/bench/streams_findbyte.cpp2
-rw-r--r--src/streams.h14
-rw-r--r--src/test/fuzz/buffered_file.cpp2
-rw-r--r--src/test/streams_tests.cpp10
-rw-r--r--src/validation.cpp4
5 files changed, 16 insertions, 16 deletions
diff --git a/src/bench/streams_findbyte.cpp b/src/bench/streams_findbyte.cpp
index 451b5f758d..22b8f1b356 100644
--- a/src/bench/streams_findbyte.cpp
+++ b/src/bench/streams_findbyte.cpp
@@ -16,7 +16,7 @@ static void FindByte(benchmark::Bench& bench)
data[file_size-1] = 1;
fwrite(&data, sizeof(uint8_t), file_size, file);
rewind(file);
- CBufferedFile bf{file, /*nBufSize=*/file_size + 1, /*nRewindIn=*/file_size, 0};
+ BufferedFile bf{file, /*nBufSize=*/file_size + 1, /*nRewindIn=*/file_size, 0};
bench.run([&] {
bf.SetPos(0);
diff --git a/src/streams.h b/src/streams.h
index eec9c0956b..f9a817c9b6 100644
--- a/src/streams.h
+++ b/src/streams.h
@@ -577,7 +577,7 @@ public:
* Will automatically close the file when it goes out of scope if not null.
* If you need to close the file early, use file.fclose() instead of fclose(file).
*/
-class CBufferedFile
+class BufferedFile
{
private:
const int nVersion;
@@ -600,7 +600,7 @@ private:
return false;
size_t nBytes = fread((void*)&vchBuf[pos], 1, readNow, src);
if (nBytes == 0) {
- throw std::ios_base::failure(feof(src) ? "CBufferedFile::Fill: end of file" : "CBufferedFile::Fill: fread failed");
+ throw std::ios_base::failure(feof(src) ? "BufferedFile::Fill: end of file" : "BufferedFile::Fill: fread failed");
}
nSrcPos += nBytes;
return true;
@@ -629,7 +629,7 @@ private:
}
public:
- CBufferedFile(FILE* fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nVersionIn)
+ BufferedFile(FILE* fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nVersionIn)
: nVersion{nVersionIn}, nReadLimit{std::numeric_limits<uint64_t>::max()}, nRewind{nRewindIn}, vchBuf(nBufSize, std::byte{0})
{
if (nRewindIn >= nBufSize)
@@ -637,14 +637,14 @@ public:
src = fileIn;
}
- ~CBufferedFile()
+ ~BufferedFile()
{
fclose();
}
// Disallow copies
- CBufferedFile(const CBufferedFile&) = delete;
- CBufferedFile& operator=(const CBufferedFile&) = delete;
+ BufferedFile(const BufferedFile&) = delete;
+ BufferedFile& operator=(const BufferedFile&) = delete;
int GetVersion() const { return nVersion; }
@@ -711,7 +711,7 @@ public:
}
template<typename T>
- CBufferedFile& operator>>(T&& obj) {
+ BufferedFile& operator>>(T&& obj) {
::Unserialize(*this, obj);
return (*this);
}
diff --git a/src/test/fuzz/buffered_file.cpp b/src/test/fuzz/buffered_file.cpp
index 47aa7e1660..1116274e3d 100644
--- a/src/test/fuzz/buffered_file.cpp
+++ b/src/test/fuzz/buffered_file.cpp
@@ -18,7 +18,7 @@ FUZZ_TARGET(buffered_file)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);
- std::optional<CBufferedFile> opt_buffered_file;
+ std::optional<BufferedFile> opt_buffered_file;
FILE* fuzzed_file = fuzzed_file_provider.open();
try {
opt_buffered_file.emplace(fuzzed_file, fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096), fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096), fuzzed_data_provider.ConsumeIntegral<int>());
diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp
index 02add89ab9..99740ee779 100644
--- a/src/test/streams_tests.cpp
+++ b/src/test/streams_tests.cpp
@@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
// The buffer size (second arg) must be greater than the rewind
// amount (third arg).
try {
- CBufferedFile bfbad{file, 25, 25, 333};
+ BufferedFile bfbad{file, 25, 25, 333};
BOOST_CHECK(false);
} catch (const std::exception& e) {
BOOST_CHECK(strstr(e.what(),
@@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
}
// The buffer is 25 bytes, allow rewinding 10 bytes.
- CBufferedFile bf{file, 25, 10, 333};
+ BufferedFile bf{file, 25, 10, 333};
BOOST_CHECK(!bf.eof());
// This member has no functional effect.
@@ -356,7 +356,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
BOOST_CHECK(false);
} catch (const std::exception& e) {
BOOST_CHECK(strstr(e.what(),
- "CBufferedFile::Fill: end of file") != nullptr);
+ "BufferedFile::Fill: end of file") != nullptr);
}
// Attempting to read beyond the end sets the EOF indicator.
BOOST_CHECK(bf.eof());
@@ -391,7 +391,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file_skip)
rewind(file);
// The buffer is 25 bytes, allow rewinding 10 bytes.
- CBufferedFile bf{file, 25, 10, 333};
+ BufferedFile bf{file, 25, 10, 333};
uint8_t i;
// This is like bf >> (7-byte-variable), in that it will cause data
@@ -445,7 +445,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file_rand)
size_t bufSize = InsecureRandRange(300) + 1;
size_t rewindSize = InsecureRandRange(bufSize);
- CBufferedFile bf{file, bufSize, rewindSize, 333};
+ BufferedFile bf{file, bufSize, rewindSize, 333};
size_t currentPos = 0;
size_t maxPos = 0;
for (int step = 0; step < 100; ++step) {
diff --git a/src/validation.cpp b/src/validation.cpp
index dce003ff2b..98a668e1b4 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -4519,8 +4519,8 @@ void ChainstateManager::LoadExternalBlockFile(
int nLoaded = 0;
try {
- // This takes over fileIn and calls fclose() on it in the CBufferedFile destructor
- CBufferedFile blkdat{fileIn, 2 * MAX_BLOCK_SERIALIZED_SIZE, MAX_BLOCK_SERIALIZED_SIZE + 8, CLIENT_VERSION};
+ // 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.
uint64_t nRewind = blkdat.GetPos();