Skip to content

Commit

Permalink
Making collect_container_info a member of nano::ledger.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Mar 29, 2024
1 parent f942d90 commit 8d7f7d2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ std::unique_ptr<nano::container_info_component> nano::collect_container_info (no
{
auto composite = std::make_unique<container_info_composite> (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"));
Expand Down
8 changes: 4 additions & 4 deletions nano/secure/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1605,12 +1605,12 @@ nano::uncemented_info::uncemented_info (nano::block_hash const & cemented_fronti
{
}

std::unique_ptr<nano::container_info_component> nano::collect_container_info (ledger & ledger, std::string const & name)
std::unique_ptr<nano::container_info_component> 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<container_info_composite> (name);
composite->add_component (std::make_unique<container_info_leaf> (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;
}
3 changes: 1 addition & 2 deletions nano/secure/ledger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class ledger final
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<container_info_component> collect_container_info (std::string const & name) const;
static nano::uint128_t const unit;
nano::ledger_constants & constants;
nano::store::component & store;
Expand All @@ -119,6 +120,4 @@ class ledger final
void initialize (nano::generate_cache_flags const &);
void confirm (nano::store::write_transaction const & transaction, nano::block const & block);
};

std::unique_ptr<container_info_component> collect_container_info (ledger & ledger, std::string const & name);
}
2 changes: 1 addition & 1 deletion nano/secure/rep_weights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ std::size_t nano::rep_weights::size () const
return rep_amounts.size ();
}

std::unique_ptr<nano::container_info_component> nano::rep_weights::collect_container_info (std::string const & name)
std::unique_ptr<nano::container_info_component> nano::rep_weights::collect_container_info (std::string const & name) const
{
size_t rep_amounts_count;

Expand Down
2 changes: 1 addition & 1 deletion nano/secure/rep_weights.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class rep_weights
/* 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<container_info_component> collect_container_info (std::string const &);
std::unique_ptr<container_info_component> collect_container_info (std::string const &) const;

private:
mutable nano::mutex mutex;
Expand Down

0 comments on commit 8d7f7d2

Please sign in to comment.