diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index f6aecb4c8..df55af7c1 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -1,3 +1,5 @@ +#include "nano/lib/numbers.hpp" + #include #include #include @@ -679,11 +681,11 @@ TEST (ledger, delete_rep_weight_of_zero) ASSERT_EQ (3, store->rep_weight.count (txn)); // set rep weights to 0 - rep_weights.representation_add (txn, 1, std::numeric_limits::max () - 99); + rep_weights.representation_add (txn, 1, nano::uint128_t{ 0 } - 100); ASSERT_EQ (2, rep_weights.size ()); ASSERT_EQ (2, store->rep_weight.count (txn)); - rep_weights.representation_add_dual (txn, 2, std::numeric_limits::max () - 99, 3, std::numeric_limits::max () - 99); + rep_weights.representation_add_dual (txn, 2, nano::uint128_t{ 0 } - 100, 3, nano::uint128_t{ 0 } - 100); ASSERT_EQ (0, rep_weights.size ()); ASSERT_EQ (0, store->rep_weight.count (txn)); } diff --git a/nano/secure/account_info.hpp b/nano/secure/account_info.hpp index bd7a7b0cc..ee850d8d2 100644 --- a/nano/secure/account_info.hpp +++ b/nano/secure/account_info.hpp @@ -31,8 +31,7 @@ public: }; /** - * Account info as of DB version 22. - * This class protects the DB upgrades from future changes of the account_info class. + * This is a snapshot of the account_info table at v22 which needs to be read for the v22 to v23 upgrade */ class account_info_v22 final { diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 7d031e2e7..bf644f822 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -1603,6 +1603,6 @@ std::unique_ptr nano::collect_container_info (le auto sizeof_element = sizeof (decltype (ledger.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 (collect_container_info (ledger.cache.rep_weights, "rep_weights")); + composite->add_component (ledger.cache.rep_weights.collect_container_info ("rep_weights")); return composite; } diff --git a/nano/secure/rep_weights.cpp b/nano/secure/rep_weights.cpp index 29a10d9cf..7be8915cf 100644 --- a/nano/secure/rep_weights.cpp +++ b/nano/secure/rep_weights.cpp @@ -124,15 +124,15 @@ std::size_t nano::rep_weights::size () const return rep_amounts.size (); } -std::unique_ptr nano::collect_container_info (nano::rep_weights const & rep_weights, std::string const & name) +std::unique_ptr nano::rep_weights::collect_container_info (std::string const & name) { size_t rep_amounts_count; { - nano::lock_guard guard (rep_weights.mutex); - rep_amounts_count = rep_weights.rep_amounts.size (); + nano::lock_guard guard (mutex); + rep_amounts_count = rep_amounts.size (); } - auto sizeof_element = sizeof (decltype (rep_weights.rep_amounts)::value_type); + auto sizeof_element = sizeof (decltype (rep_amounts)::value_type); auto composite = std::make_unique (name); composite->add_component (std::make_unique (container_info{ "rep_amounts", rep_amounts_count, sizeof_element })); return composite; diff --git a/nano/secure/rep_weights.hpp b/nano/secure/rep_weights.hpp index 52fb0013f..e29f4e0ba 100644 --- a/nano/secure/rep_weights.hpp +++ b/nano/secure/rep_weights.hpp @@ -29,6 +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 &); private: mutable nano::mutex mutex; @@ -37,9 +38,5 @@ private: void put_cache (nano::account const & account_a, nano::uint128_union const & representation_a); void put_store (store::write_transaction const & txn_a, nano::account const & rep_a, nano::uint128_t const & previous_weight_a, nano::uint128_t const & new_weight_a); nano::uint128_t get (nano::account const & account_a) const; - - friend std::unique_ptr collect_container_info (rep_weights const &, std::string const &); }; - -std::unique_ptr collect_container_info (rep_weights const &, std::string const &); }