Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework collect_container_info (..) functions #4736

Merged
merged 7 commits into from
Oct 3, 2024

Conversation

pwojcikdev
Copy link
Contributor

This simplifies how container info functionality is implemented for node components, avoiding unnecessary and annoying boilerplate.

Previously:

std::unique_ptr<nano::container_info_component> nano::block_processor::collect_container_info (std::string const & name)
{
	nano::lock_guard<nano::mutex> guard{ mutex };

	auto composite = std::make_unique<container_info_composite> (name);
	composite->add_component (std::make_unique<container_info_leaf> (container_info_entry{ "blocks", queue.size (), 0 }));
	composite->add_component (std::make_unique<container_info_leaf> (container_info_entry{ "forced", queue.size ({ nano::block_source::forced }), 0 }));
	composite->add_component (queue.collect_container_info ("queue"));
	return composite;
}

Now:

nano::container_info nano::block_processor::container_info () const
{
	nano::lock_guard<nano::mutex> guard{ mutex };

	nano::container_info info;
	info.put ("blocks", queue.size ());
	info.put ("forced", queue.size ({ nano::block_source::forced }));
	info.add ("queue", queue.container_info ());
	return info;
}

clemahieu
clemahieu previously approved these changes Sep 25, 2024
@qwahzi qwahzi added this to the V28 milestone Sep 25, 2024
clemahieu
clemahieu previously approved these changes Sep 28, 2024
# Conflicts:
#	nano/node/bootstrap_ascending/service.cpp
@pwojcikdev pwojcikdev merged commit ab093d5 into nanocurrency:develop Oct 3, 2024
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged / V28.0
Development

Successfully merging this pull request may close these issues.

3 participants