From 0027355254732be9fa163235b2cb27978292f437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 21 Mar 2024 16:53:55 +0100 Subject: [PATCH] Report unique vote count --- nano/node/vote_cache.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nano/node/vote_cache.cpp b/nano/node/vote_cache.cpp index 9f61192653..bd9c7f4046 100644 --- a/nano/node/vote_cache.cpp +++ b/nano/node/vote_cache.cpp @@ -284,8 +284,23 @@ void nano::vote_cache::cleanup () std::unique_ptr nano::vote_cache::collect_container_info (const std::string & name) const { + nano::lock_guard guard{ mutex }; + + auto count_unique_votes = [this] () { + std::unordered_set> votes; + for (auto const & entry : cache) + { + for (auto const & vote : entry.votes ()) + { + votes.insert (vote); + } + } + return votes.size (); + }; + auto composite = std::make_unique (name); - composite->add_component (std::make_unique (container_info{ "cache", size (), sizeof (ordered_cache::value_type) })); + composite->add_component (std::make_unique (container_info{ "cache", cache.size (), sizeof (ordered_cache::value_type) })); + composite->add_component (std::make_unique (container_info{ "unique", count_unique_votes (), sizeof (nano::vote) })); return composite; }