Address issues from code review
This commit is contained in:
parent
f99ba3e852
commit
ef64ecb799
5 changed files with 11 additions and 13 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "nano/lib/numbers.hpp"
|
||||||
|
|
||||||
#include <nano/lib/blocks.hpp>
|
#include <nano/lib/blocks.hpp>
|
||||||
#include <nano/lib/logging.hpp>
|
#include <nano/lib/logging.hpp>
|
||||||
#include <nano/lib/stats.hpp>
|
#include <nano/lib/stats.hpp>
|
||||||
|
|
@ -679,11 +681,11 @@ TEST (ledger, delete_rep_weight_of_zero)
|
||||||
ASSERT_EQ (3, store->rep_weight.count (txn));
|
ASSERT_EQ (3, store->rep_weight.count (txn));
|
||||||
|
|
||||||
// set rep weights to 0
|
// set rep weights to 0
|
||||||
rep_weights.representation_add (txn, 1, std::numeric_limits<nano::uint128_t>::max () - 99);
|
rep_weights.representation_add (txn, 1, nano::uint128_t{ 0 } - 100);
|
||||||
ASSERT_EQ (2, rep_weights.size ());
|
ASSERT_EQ (2, rep_weights.size ());
|
||||||
ASSERT_EQ (2, store->rep_weight.count (txn));
|
ASSERT_EQ (2, store->rep_weight.count (txn));
|
||||||
|
|
||||||
rep_weights.representation_add_dual (txn, 2, std::numeric_limits<nano::uint128_t>::max () - 99, 3, std::numeric_limits<nano::uint128_t>::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, rep_weights.size ());
|
||||||
ASSERT_EQ (0, store->rep_weight.count (txn));
|
ASSERT_EQ (0, store->rep_weight.count (txn));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account info as of DB version 22.
|
* This is a snapshot of the account_info table at v22 which needs to be read for the v22 to v23 upgrade
|
||||||
* This class protects the DB upgrades from future changes of the account_info class.
|
|
||||||
*/
|
*/
|
||||||
class account_info_v22 final
|
class account_info_v22 final
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1603,6 +1603,6 @@ std::unique_ptr<nano::container_info_component> nano::collect_container_info (le
|
||||||
auto sizeof_element = sizeof (decltype (ledger.bootstrap_weights)::value_type);
|
auto sizeof_element = sizeof (decltype (ledger.bootstrap_weights)::value_type);
|
||||||
auto composite = std::make_unique<container_info_composite> (name);
|
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 (std::make_unique<container_info_leaf> (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;
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,15 +124,15 @@ std::size_t nano::rep_weights::size () const
|
||||||
return rep_amounts.size ();
|
return rep_amounts.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<nano::container_info_component> nano::collect_container_info (nano::rep_weights const & rep_weights, std::string const & name)
|
std::unique_ptr<nano::container_info_component> nano::rep_weights::collect_container_info (std::string const & name)
|
||||||
{
|
{
|
||||||
size_t rep_amounts_count;
|
size_t rep_amounts_count;
|
||||||
|
|
||||||
{
|
{
|
||||||
nano::lock_guard<nano::mutex> guard (rep_weights.mutex);
|
nano::lock_guard<nano::mutex> guard (mutex);
|
||||||
rep_amounts_count = rep_weights.rep_amounts.size ();
|
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<nano::container_info_composite> (name);
|
auto composite = std::make_unique<nano::container_info_composite> (name);
|
||||||
composite->add_component (std::make_unique<nano::container_info_leaf> (container_info{ "rep_amounts", rep_amounts_count, sizeof_element }));
|
composite->add_component (std::make_unique<nano::container_info_leaf> (container_info{ "rep_amounts", rep_amounts_count, sizeof_element }));
|
||||||
return composite;
|
return composite;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ public:
|
||||||
/* Only use this method when loading rep weights from the database table */
|
/* Only use this method when loading rep weights from the database table */
|
||||||
void copy_from (rep_weights & other_a);
|
void copy_from (rep_weights & other_a);
|
||||||
size_t size () const;
|
size_t size () const;
|
||||||
|
std::unique_ptr<container_info_component> collect_container_info (std::string const &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable nano::mutex mutex;
|
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_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);
|
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;
|
nano::uint128_t get (nano::account const & account_a) const;
|
||||||
|
|
||||||
friend std::unique_ptr<container_info_component> collect_container_info (rep_weights const &, std::string const &);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<container_info_component> collect_container_info (rep_weights const &, std::string const &);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue