db: add StoragePath to CDBWrapper/CCoinsViewDB

This is used in subsequent commits. It allows us to clean up UTXO
snapshot chainstate after background validation completes.
This commit is contained in:
James O'Beirne
2022-02-01 16:22:00 -05:00
parent 29d540b7ad
commit d14bebf100
3 changed files with 23 additions and 1 deletions

View File

@@ -39,6 +39,10 @@ public:
class CDBWrapper;
namespace dbwrapper {
using leveldb::DestroyDB;
}
/** These should be considered an implementation detail of the specific database.
*/
namespace dbwrapper_private {
@@ -219,6 +223,12 @@ private:
std::vector<unsigned char> CreateObfuscateKey() const;
//! path to filesystem storage
const fs::path m_path;
//! whether or not the database resides in memory
bool m_is_memory;
public:
/**
* @param[in] path Location in the filesystem where leveldb data will be stored.
@@ -268,6 +278,14 @@ public:
return 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
{