mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
index: Coinstats index can be activated with command line flag
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user