What changed, and why it matters
This is a small code cleanup change in Bitcoin Core. It removes a misleading alias named DEFAULT_DB_CACHE and replaces it with the underlying name DEFAULT_KERNEL_CACHE in a few places. The behavior of the program is unchanged; only the names used in the source code are clearer.
No security action needed. Treat as routine maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit inlines the constant alias DEFAULT_DB_CACHE (which was defined as DEFAULT_KERNEL_CACHE) by replacing its usages with DEFAULT_KERNEL_CACHE directly. Affected locations: GetDefaultDBCache() in src/node/caches.cpp, ShouldWarnOversizedDbCache() in src/node/caches.h, a settings migration in src/qt/optionsmodel.cpp, and unit tests in src/test/caches_tests.cpp. The change is purely refactor/rename with no functional diff.
Changed components
src/node/caches.cppsrc/node/caches.hsrc/qt/optionsmodel.cppsrc/test/caches_tests.cppInspect captured patch +5 / −7
diff --git a/src/node/caches.cpp b/src/node/caches.cpp
index c25b3e9a..6eb2c0a3 100644
--- a/src/node/caches.cpp
+++ b/src/node/caches.cpp
@@ -41,7 +41,7 @@ uint64_t GetDefaultDBCache()
return HIGH_DEFAULT_DBCACHE;
}
}
- return DEFAULT_DB_CACHE;
+ return DEFAULT_KERNEL_CACHE;
}
uint64_t CalculateDbCacheBytes(const ArgsManager& args)
diff --git a/src/node/caches.h b/src/node/caches.h
index 756dfa37..14056a25 100644
--- a/src/node/caches.h
+++ b/src/node/caches.h
@@ -14,8 +14,6 @@
class ArgsManager;
-//! -dbcache default (bytes)
-static constexpr uint64_t DEFAULT_DB_CACHE{DEFAULT_KERNEL_CACHE};
//! Reserved non-dbcache memory usage.
static constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM{2_GiB};
@@ -34,7 +32,7 @@ CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes = 0);
constexpr bool ShouldWarnOversizedDbCache(uint64_t dbcache, uint64_t total_ram) noexcept
{
const uint64_t available_ram{total_ram > DBCACHE_WARNING_RESERVED_RAM ? total_ram - DBCACHE_WARNING_RESERVED_RAM : 0};
- const uint64_t cap{std::max<uint64_t>(DEFAULT_DB_CACHE, (available_ram / 4) * 3)};
+ const uint64_t cap{std::max(DEFAULT_KERNEL_CACHE, (available_ram / 4) * 3)};
return dbcache > cap;
}
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 49e3c4b8..9f540c87 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -732,7 +732,7 @@ void OptionsModel::checkAndMigrate()
// see https://github.com/bitcoin/bitcoin/pull/8273
// force people to upgrade to the new value if they are using 100MB
if (settingsVersion < 130000 && settings.contains("nDatabaseCache") && settings.value("nDatabaseCache").toLongLong() == 100)
- settings.setValue("nDatabaseCache", qint64(DEFAULT_DB_CACHE / 1_MiB));
+ settings.setValue("nDatabaseCache", qint64(DEFAULT_KERNEL_CACHE / 1_MiB));
settings.setValue(strSettingsVersionKey, CLIENT_VERSION);
}
diff --git a/src/test/caches_tests.cpp b/src/test/caches_tests.cpp
index 15820a79..1291eb33 100644
--- a/src/test/caches_tests.cpp
+++ b/src/test/caches_tests.cpp
@@ -27,8 +27,8 @@ BOOST_AUTO_TEST_CASE(oversized_dbcache_warning)
BOOST_CHECK(!ShouldWarnOversizedDbCache(MIN_DBCACHE_BYTES, 1_GiB));
// Below DBCACHE_WARNING_RESERVED_RAM the existing fixed default dominates.
- CheckDbCacheWarnThreshold(DEFAULT_DB_CACHE, 1_GiB);
- CheckDbCacheWarnThreshold(DEFAULT_DB_CACHE, DBCACHE_WARNING_RESERVED_RAM);
+ CheckDbCacheWarnThreshold(DEFAULT_KERNEL_CACHE, 1_GiB);
+ CheckDbCacheWarnThreshold(DEFAULT_KERNEL_CACHE, DBCACHE_WARNING_RESERVED_RAM);
// Above DBCACHE_WARNING_RESERVED_RAM the warning fires at 75% of the headroom.
CheckDbCacheWarnThreshold(((3_GiB - DBCACHE_WARNING_RESERVED_RAM) / 4) * 3, 3_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.