dbwrapper: make max_file_size a configurable DBParams field

Useful for fuzzing different values.
This commit is contained in:
Andrew Toth
2026-03-21 11:20:48 -04:00
parent 483769c046
commit 8d390c93fc
2 changed files with 4 additions and 1 deletions

View File

@@ -149,7 +149,6 @@ static leveldb::Options GetOptions(size_t nCacheSize)
// on corruption in later versions.
options.paranoid_checks = true;
}
options.max_file_size = std::max(options.max_file_size, DBWRAPPER_MAX_FILE_SIZE);
SetMaxOpenFiles(&options);
return options;
}
@@ -224,6 +223,7 @@ CDBWrapper::CDBWrapper(const DBParams& params)
DBContext().syncoptions.sync = true;
DBContext().options = GetOptions(params.cache_bytes);
DBContext().options.create_if_missing = true;
DBContext().options.max_file_size = params.max_file_size;
if (params.memory_only) {
DBContext().penv = leveldb::NewMemEnv(leveldb::Env::Default());
DBContext().options.env = DBContext().penv;

View File

@@ -44,6 +44,9 @@ struct DBParams {
bool obfuscate = false;
//! Passed-through options.
DBOptions options{};
//! Maximum LevelDB SST file size. Larger values reduce the frequency
//! of compactions but increase their duration.
size_t max_file_size = DBWRAPPER_MAX_FILE_SIZE;
};
class dbwrapper_error : public std::runtime_error