refactor: rename async coin compaction
What changed, and why it matters
This commit is a simple rename of an internal function from CompactFull() to CompactFullAsync(). It does not change what the code does, only its name, to make it clearer that the operation runs in the background rather than blocking. There is no security issue here.
No action required. This is a benign refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change renames CCoinsViewDB::CompactFull() to CCoinsViewDB::CompactFullAsync() and updates all call sites in coins_tests.cpp, txdb.cpp/h, and validation.cpp. The function signature, return type (std::shared_future
Changed components
src/txdb.cppsrc/txdb.hsrc/validation.cppsrc/test/coins_tests.cppInspect captured patch +4 / −4
diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp
index 3487a178..6ae5f2b7 100644
--- a/src/test/coins_tests.cpp
+++ b/src/test/coins_tests.cpp
@@ -1078,7 +1078,7 @@ BOOST_FIXTURE_TEST_CASE(coins_db_leveldb_layout, FlushTest)
cache.Sync();
BOOST_CHECK_EQUAL(level2_files(base), 0);
- WITH_LOCK(::cs_main, return base.CompactFull()).wait();
+ WITH_LOCK(::cs_main, return base.CompactFullAsync()).wait();
BOOST_CHECK_EQUAL(level2_files(base), 1);
BOOST_CHECK(*Assert(base.GetCoin(outpoint)) == coin);
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 632c554c..8ea0407b 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -195,7 +195,7 @@ std::optional<std::string> CCoinsViewDB::GetDBProperty(const std::string& proper
return m_db->GetProperty(property);
}
-std::shared_future<void> CCoinsViewDB::CompactFull()
+std::shared_future<void> CCoinsViewDB::CompactFullAsync()
{
AssertLockHeld(::cs_main);
if (m_compaction.valid() && m_compaction.wait_for(std::chrono::seconds{0}) != std::future_status::ready) return m_compaction;
diff --git a/src/txdb.h b/src/txdb.h
index e8986421..8d4e2cc8 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -62,7 +62,7 @@ public:
void ResizeCache(size_t new_cache_size) EXCLUSIVE_LOCKS_REQUIRED(cs_main, !m_db_mutex);
//! Perform a full compaction of the underlying LevelDB on a one-shot background thread.
- std::shared_future<void> CompactFull() EXCLUSIVE_LOCKS_REQUIRED(cs_main, !m_db_mutex);
+ std::shared_future<void> CompactFullAsync() EXCLUSIVE_LOCKS_REQUIRED(cs_main, !m_db_mutex);
//! Return an underlying LevelDB property value, if available.
std::optional<std::string> GetDBProperty(const std::string& property);
diff --git a/src/validation.cpp b/src/validation.cpp
index d3f832f4..87cf646b 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2840,7 +2840,7 @@ bool Chainstate::FlushStateToDisk(
if (!m_chainman.m_interrupt && ShouldCompactChainstate(m_chainman.IsInitialBlockDownload())) {
try {
- CoinsDB().CompactFull();
+ CoinsDB().CompactFullAsync();
} catch (const std::exception& e) {
LogWarning("Failed to start chainstate compaction (%s)", e.what());
}
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.