aboutsummaryrefslogtreecommitdiff
path: root/src/index
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2020-07-31 14:01:31 +0200
committerFabian Jahr <fjahr@protonmail.com>2020-08-16 11:15:49 +0200
commit667bc7a7f7c5d9a15eaf6957c3d8841a75efa7bc (patch)
tree4442244be84cec6d061efd0a12dc4f33d605147e /src/index
parenta57af897ec16976b28de05aa0b9c3f6a96d73ede (diff)
rpc: Add getindexinfo RPC
Diffstat (limited to 'src/index')
-rw-r--r--src/index/base.cpp9
-rw-r--r--src/index/base.h9
2 files changed, 18 insertions, 0 deletions
diff --git a/src/index/base.cpp b/src/index/base.cpp
index f587205a28..e67b813763 100644
--- a/src/index/base.cpp
+++ b/src/index/base.cpp
@@ -319,3 +319,12 @@ void BaseIndex::Stop()
m_thread_sync.join();
}
}
+
+IndexSummary BaseIndex::GetSummary() const
+{
+ IndexSummary summary{};
+ summary.name = GetName();
+ summary.synced = m_synced;
+ summary.best_block_height = m_best_block_index.load()->nHeight;
+ return summary;
+}
diff --git a/src/index/base.h b/src/index/base.h
index 3fab810bb2..74bc1ebfd2 100644
--- a/src/index/base.h
+++ b/src/index/base.h
@@ -13,6 +13,12 @@
class CBlockIndex;
+struct IndexSummary {
+ std::string name;
+ bool synced{false};
+ int best_block_height{0};
+};
+
/**
* Base class for indices of blockchain data. This implements
* CValidationInterface and ensures blocks are indexed sequentially according
@@ -106,6 +112,9 @@ public:
/// Stops the instance from staying in sync with blockchain updates.
void Stop();
+
+ /// Get a summary of the index and its state.
+ IndexSummary GetSummary() const;
};
#endif // BITCOIN_INDEX_BASE_H