From 7bbbc15db0fe81d8983421b7991fdaf2c33c51e8 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 17 Dec 2024 11:39:31 -0600 Subject: [PATCH] fixup: avoid expensive evaluations in stats code --- src/evo/deterministicmns.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index f48c59c977..b2a36543a2 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -646,14 +646,16 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, gsl::not_nullgauge("masternodes.count", newList.GetAllMNsCount()); - ::g_stats_client->gauge("masternodes.weighted_count", newList.GetValidWeightedMNsCount()); - ::g_stats_client->gauge("masternodes.enabled", newList.GetValidMNsCount()); - ::g_stats_client->gauge("masternodes.weighted_enabled", newList.GetValidWeightedMNsCount()); - ::g_stats_client->gauge("masternodes.evo.count", newList.GetAllEvoCount()); - ::g_stats_client->gauge("masternodes.evo.enabled", newList.GetValidEvoCount()); - ::g_stats_client->gauge("masternodes.mn.count", newList.GetAllMNsCount() - newList.GetAllEvoCount()); - ::g_stats_client->gauge("masternodes.mn.enabled", newList.GetValidMNsCount() - newList.GetValidEvoCount()); + if (::g_stats_client->active()) { + ::g_stats_client->gauge("masternodes.count", newList.GetAllMNsCount()); + ::g_stats_client->gauge("masternodes.weighted_count", newList.GetValidWeightedMNsCount()); + ::g_stats_client->gauge("masternodes.enabled", newList.GetValidMNsCount()); + ::g_stats_client->gauge("masternodes.weighted_enabled", newList.GetValidWeightedMNsCount()); + ::g_stats_client->gauge("masternodes.evo.count", newList.GetAllEvoCount()); + ::g_stats_client->gauge("masternodes.evo.enabled", newList.GetValidEvoCount()); + ::g_stats_client->gauge("masternodes.mn.count", newList.GetAllMNsCount() - newList.GetAllEvoCount()); + ::g_stats_client->gauge("masternodes.mn.enabled", newList.GetValidMNsCount() - newList.GetValidEvoCount()); + } if (nHeight == consensusParams.DIP0003EnforcementHeight) { if (!consensusParams.DIP0003EnforcementHash.IsNull() && consensusParams.DIP0003EnforcementHash != pindex->GetBlockHash()) {