Skip to content

Commit ebbc1dd

Browse files
fixup: avoid expensive evaluations in stats code
1 parent 83d9f73 commit ebbc1dd

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/evo/deterministicmns.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,16 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, gsl::not_null<co
650650
updatesRet = {newList, oldList, diff};
651651
}
652652

653-
::g_stats_client->gauge("masternodes.count", newList.GetAllMNsCount());
654-
::g_stats_client->gauge("masternodes.weighted_count", newList.GetValidWeightedMNsCount());
655-
::g_stats_client->gauge("masternodes.enabled", newList.GetValidMNsCount());
656-
::g_stats_client->gauge("masternodes.weighted_enabled", newList.GetValidWeightedMNsCount());
657-
::g_stats_client->gauge("masternodes.evo.count", newList.GetAllEvoCount());
658-
::g_stats_client->gauge("masternodes.evo.enabled", newList.GetValidEvoCount());
659-
::g_stats_client->gauge("masternodes.mn.count", newList.GetAllMNsCount() - newList.GetAllEvoCount());
660-
::g_stats_client->gauge("masternodes.mn.enabled", newList.GetValidMNsCount() - newList.GetValidEvoCount());
653+
if (::g_stats_client->active()) {
654+
::g_stats_client->gauge("masternodes.count", newList.GetAllMNsCount());
655+
::g_stats_client->gauge("masternodes.weighted_count", newList.GetValidWeightedMNsCount());
656+
::g_stats_client->gauge("masternodes.enabled", newList.GetValidMNsCount());
657+
::g_stats_client->gauge("masternodes.weighted_enabled", newList.GetValidWeightedMNsCount());
658+
::g_stats_client->gauge("masternodes.evo.count", newList.GetAllEvoCount());
659+
::g_stats_client->gauge("masternodes.evo.enabled", newList.GetValidEvoCount());
660+
::g_stats_client->gauge("masternodes.mn.count", newList.GetAllMNsCount() - newList.GetAllEvoCount());
661+
::g_stats_client->gauge("masternodes.mn.enabled", newList.GetValidMNsCount() - newList.GetValidEvoCount());
662+
}
661663

662664
if (nHeight == consensusParams.DIP0003EnforcementHeight) {
663665
if (!consensusParams.DIP0003EnforcementHash.IsNull() && consensusParams.DIP0003EnforcementHash != pindex->GetBlockHash()) {

0 commit comments

Comments
 (0)