From cc20a5b1633b2fee9a7d39fafba242b313bcaaa6 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Fri, 29 Mar 2024 22:11:51 +0000 Subject: [PATCH] Making collect_container_info a member of nano::ledger. --- nano/node/node.cpp | 2 +- nano/secure/ledger.cpp | 8 ++++---- nano/secure/ledger.hpp | 3 +-- nano/secure/rep_weights.cpp | 2 +- nano/secure/rep_weights.hpp | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/nano/node/node.cpp b/nano/node/node.cpp index c21f9818d..6be3dc66b 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -554,7 +554,7 @@ std::unique_ptr nano::collect_container_info (no { auto composite = std::make_unique (name); composite->add_component (collect_container_info (node.work, "work")); - composite->add_component (collect_container_info (node.ledger, "ledger")); + composite->add_component (node.ledger.collect_container_info ("ledger")); composite->add_component (collect_container_info (node.active, "active")); composite->add_component (collect_container_info (node.bootstrap_initiator, "bootstrap_initiator")); composite->add_component (node.tcp_listener->collect_container_info ("tcp_listener")); diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 1f2f373a0..35965a297 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -1605,12 +1605,12 @@ nano::uncemented_info::uncemented_info (nano::block_hash const & cemented_fronti { } -std::unique_ptr nano::collect_container_info (ledger & ledger, std::string const & name) +std::unique_ptr nano::ledger::collect_container_info (std::string const & name) const { - auto count = ledger.bootstrap_weights.size (); - auto sizeof_element = sizeof (decltype (ledger.bootstrap_weights)::value_type); + auto count = bootstrap_weights.size (); + auto sizeof_element = sizeof (decltype (bootstrap_weights)::value_type); auto composite = std::make_unique (name); composite->add_component (std::make_unique (container_info{ "bootstrap_weights", count, sizeof_element })); - composite->add_component (ledger.cache.rep_weights.collect_container_info ("rep_weights")); + composite->add_component (cache.rep_weights.collect_container_info ("rep_weights")); return composite; } diff --git a/nano/secure/ledger.hpp b/nano/secure/ledger.hpp index 1d25da133..6ddf472fe 100644 --- a/nano/secure/ledger.hpp +++ b/nano/secure/ledger.hpp @@ -103,6 +103,7 @@ public: nano::receivable_iterator receivable_upper_bound (store::transaction const & tx, nano::account const & account) const; // Returns the next receivable entry for the account 'account' with hash greater than 'hash' nano::receivable_iterator receivable_upper_bound (store::transaction const & tx, nano::account const & account, nano::block_hash const & hash) const; + std::unique_ptr collect_container_info (std::string const & name) const; static nano::uint128_t const unit; nano::ledger_constants & constants; nano::store::component & store; @@ -119,6 +120,4 @@ private: void initialize (nano::generate_cache_flags const &); void confirm (nano::store::write_transaction const & transaction, nano::block const & block); }; - -std::unique_ptr collect_container_info (ledger & ledger, std::string const & name); } diff --git a/nano/secure/rep_weights.cpp b/nano/secure/rep_weights.cpp index 632ace73a..7b9622ae0 100644 --- a/nano/secure/rep_weights.cpp +++ b/nano/secure/rep_weights.cpp @@ -126,7 +126,7 @@ std::size_t nano::rep_weights::size () const return rep_amounts.size (); } -std::unique_ptr nano::rep_weights::collect_container_info (std::string const & name) +std::unique_ptr nano::rep_weights::collect_container_info (std::string const & name) const { size_t rep_amounts_count; diff --git a/nano/secure/rep_weights.hpp b/nano/secure/rep_weights.hpp index 214e22b8e..f90bf19b7 100644 --- a/nano/secure/rep_weights.hpp +++ b/nano/secure/rep_weights.hpp @@ -29,7 +29,7 @@ public: /* Only use this method when loading rep weights from the database table */ void copy_from (rep_weights & other_a); size_t size () const; - std::unique_ptr collect_container_info (std::string const &); + std::unique_ptr collect_container_info (std::string const &) const; private: mutable nano::mutex mutex;