<details><summary>Another approach :smile: </summary><p>
diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp
index b9029e946a..a554cd4e3b 100644
--- a/src/index/coinstatsindex.cpp
+++ b/src/index/coinstatsindex.cpp
@@ -23,6 +23,7 @@ using node::UndoReadFromDisk;
static constexpr uint8_t DB_MUHASH{'M'};
+static const std::string index_name{"coinstatsindex"};
@@ -392,6 +393,8 @@ bool CoinStatsIndex::CustomInit(const std::optional<interfaces::BlockKey>& block
+const std::string& CoinStatsIndex::GetName() const { return index_name; }
+
bool CoinStatsIndex::CustomCommit(CDBBatch& batch)
diff --git a/src/index/coinstatsindex.h b/src/index/coinstatsindex.h
index 91a30fb9d9..54fff61e53 100644
--- a/src/index/coinstatsindex.h
+++ b/src/index/coinstatsindex.h
@@ -51,11 +51,7 @@ protected:
- const std::string& GetName() const override
- {
- static std::string name{"coinstatsindex"};
- return name;
- }
+ const std::string& GetName() const override;
public:
// Constructs the index, which becomes available to be queried.
diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp
index b719aface8..489bcd53c0 100644
--- a/src/index/txindex.cpp
+++ b/src/index/txindex.cpp
@@ -12,6 +12,7 @@
constexpr uint8_t DB_TXINDEX{'t'};
+static const std::string index_name{"txindex"};
@@ -54,6 +55,8 @@ TxIndex::TxIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size,
+const std::string& TxIndex::GetName() const { return index_name; }
+
bool TxIndex::CustomAppend(const interfaces::BlockInfo& block)
{
// Exclude genesis block transaction because outputs are not spendable.
diff --git a/src/index/txindex.h b/src/index/txindex.h
index cf0ecf498f..c54ad562d8 100644
--- a/src/index/txindex.h
+++ b/src/index/txindex.h
@@ -29,11 +29,7 @@ protected:
- const std::string& GetName() const override
- {
- static std::string name{"txindex"};
- return name;
- }
+ const std::string& GetName() const override;
public:
``
</p></details>