mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 21:52:53 +02:00
coins: test chainstate flush baseline
Add `CDBWrapper::GetProperty()` and expose it through `CCoinsViewDB::GetDBProperty()` so coins tests can inspect LevelDB runtime properties through the coins view. Use it in a coins DB flush baseline that records the LevelDB layout after flushing while keeping readback coverage for the flushed coin and best block. Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
This commit is contained in:
@@ -301,11 +301,16 @@ void CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync)
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> CDBWrapper::GetProperty(const std::string& property) const
|
||||
{
|
||||
if (std::string value; DBContext().pdb->GetProperty(property, &value)) return value;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
size_t CDBWrapper::DynamicMemoryUsage() const
|
||||
{
|
||||
std::string memory;
|
||||
std::optional<size_t> parsed;
|
||||
if (!DBContext().pdb->GetProperty("leveldb.approximate-memory-usage", &memory) || !(parsed = ToIntegral<size_t>(memory))) {
|
||||
if (auto memory{GetProperty("leveldb.approximate-memory-usage")}; !memory || !(parsed = ToIntegral<size_t>(*memory))) {
|
||||
LogDebug(BCLog::LEVELDB, "Failed to get approximate-memory-usage property\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user