scripted-diff: use `MIN_DBCACHE_BYTES`
What changed, and why it matters
This commit is a simple automated rename of a constant from MIN_DB_CACHE to MIN_DBCACHE_BYTES across five files. The value stays the same (4 MiB), and no behavior changes. It is a code-cleanup/refactoring change with no security relevance.
No security action needed; this is a non-functional rename.
Security signals we found
No strong security signals were identified.
Evidence from the diff
A scripted-diff renames the internal constant MIN_DB_CACHE to MIN_DBCACHE_BYTES in src/node/caches.h and updates all references in src/init.cpp, src/node/caches.cpp, src/qt/optionsdialog.cpp, and src/test/caches_tests.cpp. The numeric value remains 4_MiB and all logic is unchanged.
Changed components
src/init.cppsrc/node/caches.cppsrc/node/caches.hsrc/qt/optionsdialog.cppsrc/test/caches_tests.cppInspect captured patch +5 / −5
diff --git a/src/init.cpp b/src/init.cpp
index 44f06079..c25e07bf 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -530,7 +530,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS);
argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", DEFAULT_DB_CACHE_BATCH), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS);
- argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", MIN_DB_CACHE / 1_MiB, node::GetDefaultDBCache() / 1_MiB), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
+ argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", MIN_DBCACHE_BYTES / 1_MiB, node::GetDefaultDBCache() / 1_MiB), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-includeconf=<file>", "Specify additional configuration file, relative to the -datadir path (only useable from configuration file, not command line)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-allowignoredconf", strprintf("For backwards compatibility, treat an unused %s file in the datadir as a warning, not an error.", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-loadblock=<file>", "Imports blocks from an external file on startup. Obfuscated blocks are not supported.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
diff --git a/src/node/caches.cpp b/src/node/caches.cpp
index ea69c717..37b674fa 100644
--- a/src/node/caches.cpp
+++ b/src/node/caches.cpp
@@ -53,7 +53,7 @@ uint64_t CalculateDbCacheBytes(const ArgsManager& args)
if (*db_cache < 0) db_cache = 0;
const uint64_t db_cache_bytes{SaturatingLeftShift<uint64_t>(*db_cache, 20)};
constexpr uint64_t max_db_cache{sizeof(void*) == 4 ? MAX_32BIT_DBCACHE : std::numeric_limits<uint64_t>::max()};
- return std::max<uint64_t>(MIN_DB_CACHE, std::min<uint64_t>(db_cache_bytes, max_db_cache));
+ return std::max<uint64_t>(MIN_DBCACHE_BYTES, std::min<uint64_t>(db_cache_bytes, max_db_cache));
}
return GetDefaultDBCache();
}
diff --git a/src/node/caches.h b/src/node/caches.h
index 4fd14ed9..8bfd499b 100644
--- a/src/node/caches.h
+++ b/src/node/caches.h
@@ -15,7 +15,7 @@
class ArgsManager;
//! min. -dbcache (bytes)
-static constexpr uint64_t MIN_DB_CACHE{4_MiB};
+static constexpr uint64_t MIN_DBCACHE_BYTES{4_MiB};
//! -dbcache default (bytes)
static constexpr uint64_t DEFAULT_DB_CACHE{DEFAULT_KERNEL_CACHE};
//! Reserved non-dbcache memory usage.
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index a68829c2..e7b769c4 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -95,7 +95,7 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
ui->verticalLayout->setStretchFactor(ui->tabWidget, 1);
/* Main elements init */
- ui->databaseCache->setRange(MIN_DB_CACHE / 1_MiB, std::numeric_limits<int>::max());
+ ui->databaseCache->setRange(MIN_DBCACHE_BYTES / 1_MiB, std::numeric_limits<int>::max());
ui->threadsScriptVerif->setMinimum(-GetNumCores());
ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
ui->pruneWarning->setVisible(false);
diff --git a/src/test/caches_tests.cpp b/src/test/caches_tests.cpp
index c96bef7e..8144aac0 100644
--- a/src/test/caches_tests.cpp
+++ b/src/test/caches_tests.cpp
@@ -23,7 +23,7 @@ BOOST_AUTO_TEST_SUITE(caches_tests)
BOOST_AUTO_TEST_CASE(oversized_dbcache_warning)
{
- BOOST_CHECK(!ShouldWarnOversizedDbCache(MIN_DB_CACHE, 1_GiB));
+ BOOST_CHECK(!ShouldWarnOversizedDbCache(MIN_DBCACHE_BYTES, 1_GiB));
// Below DBCACHE_WARNING_RESERVED_RAM the existing fixed default dominates.
CheckDbCacheWarnThreshold(DEFAULT_DB_CACHE, 1_GiB);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.