aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2020-01-24 18:58:47 +0100
committerFabian Jahr <fjahr@protonmail.com>2021-04-19 20:28:48 +0200
commit3c914d58ff323255b32e717d0ce28209ec0abdaa (patch)
tree34187e016ca1869013b06f76027cbdd624263e45 /src/node
parentdd58a4de21469d6d848ae309edc47f558628221d (diff)
downloadbitcoin-3c914d58ff323255b32e717d0ce28209ec0abdaa.tar.xz
index: Coinstats index can be activated with command line flag
Diffstat (limited to 'src/node')
-rw-r--r--src/node/coinstats.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp
index a9af53ca80..dc9d32035d 100644
--- a/src/node/coinstats.cpp
+++ b/src/node/coinstats.cpp
@@ -8,6 +8,7 @@
#include <coins.h>
#include <crypto/muhash.h>
#include <hash.h>
+#include <index/coinstatsindex.h>
#include <serialize.h>
#include <uint256.h>
#include <util/system.h>
@@ -92,13 +93,19 @@ static bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats&
{
std::unique_ptr<CCoinsViewCursor> pcursor(view->Cursor());
assert(pcursor);
-
stats.hashBlock = pcursor->GetBestBlock();
+
+ const CBlockIndex* pindex;
{
LOCK(cs_main);
assert(std::addressof(g_chainman.m_blockman) == std::addressof(blockman));
- const CBlockIndex* block = blockman.LookupBlockIndex(stats.hashBlock);
- stats.nHeight = Assert(block)->nHeight;
+ pindex = blockman.LookupBlockIndex(stats.hashBlock);
+ stats.nHeight = Assert(pindex)->nHeight;
+ }
+
+ // Use CoinStatsIndex if it is available and a hash_type of Muhash or None was requested
+ if ((stats.m_hash_type == CoinStatsHashType::MUHASH || stats.m_hash_type == CoinStatsHashType::NONE) && g_coin_stats_index) {
+ return g_coin_stats_index->LookUpStats(pindex, stats);
}
PrepareHash(hash_obj, stats);