refactor: Add Chainstate::StoragePath() method

Use to simplify code determining the chainstate leveldb paths. New method is
the now the only code that needs to figure out the storage path, so the path
doesn't need to be constructed multiple places and backed out of leveldb.
This commit is contained in:
Ryan Ofsky
2024-05-30 11:25:04 -04:00
parent 840bd2ef23
commit a9b7f5614c
8 changed files with 45 additions and 89 deletions

View File

@@ -191,12 +191,6 @@ private:
//! obfuscation key storage key, null-prefixed to avoid collisions
inline static const std::string OBFUSCATION_KEY{"\000obfuscate_key", 14}; // explicit size to avoid truncation at leading \0
//! path to filesystem storage
const fs::path m_path;
//! whether or not the database resides in memory
bool m_is_memory;
std::optional<std::string> ReadImpl(std::span<const std::byte> key) const;
bool ExistsImpl(std::span<const std::byte> key) const;
size_t EstimateSizeImpl(std::span<const std::byte> key1, std::span<const std::byte> key2) const;
@@ -237,14 +231,6 @@ public:
WriteBatch(batch, fSync);
}
//! @returns filesystem path to the on-disk data.
std::optional<fs::path> StoragePath() {
if (m_is_memory) {
return {};
}
return m_path;
}
template <typename K>
bool Exists(const K& key) const
{