Renaming election_behavior::normal to election_behavior::priority
This commit is contained in:
parent
f9d1b8844f
commit
433e0c9d6d
11 changed files with 23 additions and 23 deletions
|
|
@ -1487,7 +1487,7 @@ TEST (active_elections, limit_vote_hinted_elections)
|
|||
ASSERT_TIMELY (5s, nano::test::active (node, { open1 }));
|
||||
|
||||
// Ensure there was no overflow of elections
|
||||
ASSERT_EQ (0, node.stats.count (nano::stat::type::active_dropped, nano::stat::detail::normal));
|
||||
ASSERT_EQ (0, node.stats.count (nano::stat::type::active_dropped, nano::stat::detail::priority));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ TEST (confirmation_solicitor, batches)
|
|||
nano::lock_guard<nano::mutex> guard (node2.active.mutex);
|
||||
for (size_t i (0); i < nano::network::confirm_req_hashes_max; ++i)
|
||||
{
|
||||
auto election (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::normal));
|
||||
auto election (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::priority));
|
||||
ASSERT_FALSE (solicitor.add (*election));
|
||||
}
|
||||
// Reached the maximum amount of requests for the channel
|
||||
auto election (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::normal));
|
||||
auto election (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::priority));
|
||||
// Broadcasting should be immediate
|
||||
ASSERT_EQ (0, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::out));
|
||||
ASSERT_FALSE (solicitor.broadcast (*election));
|
||||
|
|
@ -92,7 +92,7 @@ TEST (confirmation_solicitor, different_hash)
|
|||
.work (*system.work.generate (nano::dev::genesis->hash ()))
|
||||
.build ();
|
||||
send->sideband_set ({});
|
||||
auto election (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::normal));
|
||||
auto election (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::priority));
|
||||
// Add a vote for something else, not the winner
|
||||
election->last_votes[representative.account] = { std::chrono::steady_clock::now (), 1, 1 };
|
||||
// Ensure the request and broadcast goes through
|
||||
|
|
@ -136,7 +136,7 @@ TEST (confirmation_solicitor, bypass_max_requests_cap)
|
|||
.work (*system.work.generate (nano::dev::genesis->hash ()))
|
||||
.build ();
|
||||
send->sideband_set ({});
|
||||
auto election (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::normal));
|
||||
auto election (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::priority));
|
||||
// Add a vote for something else, not the winner
|
||||
for (auto const & rep : representatives)
|
||||
{
|
||||
|
|
@ -149,7 +149,7 @@ TEST (confirmation_solicitor, bypass_max_requests_cap)
|
|||
ASSERT_TIMELY_EQ (6s, max_representatives + 1, node2.stats.count (nano::stat::type::message, nano::stat::detail::confirm_req, nano::stat::dir::out));
|
||||
|
||||
solicitor.prepare (representatives);
|
||||
auto election2 (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::normal));
|
||||
auto election2 (std::make_shared<nano::election> (node2, send, nullptr, nullptr, nano::election_behavior::priority));
|
||||
ASSERT_FALSE (solicitor.add (*election2));
|
||||
ASSERT_FALSE (solicitor.broadcast (*election2));
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ TEST (election, construction)
|
|||
nano::test::system system (1);
|
||||
auto & node = *system.nodes[0];
|
||||
auto election = std::make_shared<nano::election> (
|
||||
node, nano::dev::genesis, [] (auto const &) {}, [] (auto const &) {}, nano::election_behavior::normal);
|
||||
node, nano::dev::genesis, [] (auto const &) {}, [] (auto const &) {}, nano::election_behavior::priority);
|
||||
}
|
||||
|
||||
TEST (election, behavior)
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ enum class detail
|
|||
|
||||
// election types
|
||||
manual,
|
||||
normal,
|
||||
priority,
|
||||
hinted,
|
||||
optimistic,
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ int64_t nano::active_elections::limit (nano::election_behavior behavior) const
|
|||
{
|
||||
return std::numeric_limits<int64_t>::max ();
|
||||
}
|
||||
case nano::election_behavior::normal:
|
||||
case nano::election_behavior::priority:
|
||||
{
|
||||
return static_cast<int64_t> (config.size);
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ int64_t nano::active_elections::vacancy (nano::election_behavior behavior) const
|
|||
{
|
||||
case nano::election_behavior::manual:
|
||||
return std::numeric_limits<int64_t>::max ();
|
||||
case nano::election_behavior::normal:
|
||||
case nano::election_behavior::priority:
|
||||
return limit () - static_cast<int64_t> (roots.size ());
|
||||
case nano::election_behavior::hinted:
|
||||
case nano::election_behavior::optimistic:
|
||||
|
|
@ -563,7 +563,7 @@ std::unique_ptr<nano::container_info_component> nano::collect_container_info (ac
|
|||
auto composite = std::make_unique<container_info_composite> (name);
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "roots", active_elections.roots.size (), sizeof (decltype (active_elections.roots)::value_type) }));
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "election_winner_details", active_elections.election_winner_details_size (), sizeof (decltype (active_elections.election_winner_details)::value_type) }));
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "normal", static_cast<std::size_t> (active_elections.count_by_behavior[nano::election_behavior::normal]), 0 }));
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "normal", static_cast<std::size_t> (active_elections.count_by_behavior[nano::election_behavior::priority]), 0 }));
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "hinted", static_cast<std::size_t> (active_elections.count_by_behavior[nano::election_behavior::hinted]), 0 }));
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "optimistic", static_cast<std::size_t> (active_elections.count_by_behavior[nano::election_behavior::optimistic]), 0 }));
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public:
|
|||
/**
|
||||
* Starts new election with a specified behavior type
|
||||
*/
|
||||
nano::election_insertion_result insert (std::shared_ptr<nano::block> const &, nano::election_behavior = nano::election_behavior::normal);
|
||||
nano::election_insertion_result insert (std::shared_ptr<nano::block> const &, nano::election_behavior = nano::election_behavior::priority);
|
||||
// Is the root of this block in the roots container
|
||||
bool active (nano::block const &) const;
|
||||
bool active (nano::qualified_root const &) const;
|
||||
|
|
@ -128,11 +128,11 @@ public:
|
|||
* Maximum number of elections that should be present in this container
|
||||
* NOTE: This is only a soft limit, it is possible for this container to exceed this count
|
||||
*/
|
||||
int64_t limit (nano::election_behavior behavior = nano::election_behavior::normal) const;
|
||||
int64_t limit (nano::election_behavior behavior = nano::election_behavior::priority) const;
|
||||
/**
|
||||
* How many election slots are available for specified election type
|
||||
*/
|
||||
int64_t vacancy (nano::election_behavior behavior = nano::election_behavior::normal) const;
|
||||
int64_t vacancy (nano::election_behavior behavior = nano::election_behavior::priority) const;
|
||||
std::function<void ()> vacancy_update{ [] () {} };
|
||||
|
||||
std::size_t election_winner_details_size ();
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ std::chrono::milliseconds nano::election::confirm_req_time () const
|
|||
switch (behavior ())
|
||||
{
|
||||
case election_behavior::manual:
|
||||
case election_behavior::normal:
|
||||
case election_behavior::priority:
|
||||
case election_behavior::hinted:
|
||||
return base_latency () * 5;
|
||||
case election_behavior::optimistic:
|
||||
|
|
@ -297,7 +297,7 @@ std::chrono::milliseconds nano::election::time_to_live () const
|
|||
switch (behavior ())
|
||||
{
|
||||
case election_behavior::manual:
|
||||
case election_behavior::normal:
|
||||
case election_behavior::priority:
|
||||
return std::chrono::milliseconds (5 * 60 * 1000);
|
||||
case election_behavior::hinted:
|
||||
case election_behavior::optimistic:
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ private:
|
|||
mutable nano::uint128_t final_weight{ 0 };
|
||||
mutable std::unordered_map<nano::block_hash, nano::uint128_t> last_tally;
|
||||
|
||||
nano::election_behavior const behavior_m{ nano::election_behavior::normal };
|
||||
nano::election_behavior const behavior_m{ nano::election_behavior::priority };
|
||||
std::chrono::steady_clock::time_point const election_start{ std::chrono::steady_clock::now () };
|
||||
|
||||
mutable nano::mutex mutex;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace nano
|
|||
enum class election_behavior
|
||||
{
|
||||
manual,
|
||||
normal,
|
||||
priority,
|
||||
/**
|
||||
* Hinted elections:
|
||||
* - shorter timespan
|
||||
|
|
|
|||
|
|
@ -2010,7 +2010,7 @@ void nano::json_handler::election_statistics ()
|
|||
{
|
||||
auto active_elections = node.active.list_active ();
|
||||
unsigned manual_count = 0;
|
||||
unsigned normal_count = 0;
|
||||
unsigned priority_count = 0;
|
||||
unsigned hinted_count = 0;
|
||||
unsigned optimistic_count = 0;
|
||||
unsigned total_count = 0;
|
||||
|
|
@ -2031,8 +2031,8 @@ void nano::json_handler::election_statistics ()
|
|||
case election_behavior::manual:
|
||||
manual_count++;
|
||||
break;
|
||||
case election_behavior::normal:
|
||||
normal_count++;
|
||||
case election_behavior::priority:
|
||||
priority_count++;
|
||||
break;
|
||||
case election_behavior::hinted:
|
||||
hinted_count++;
|
||||
|
|
@ -2051,7 +2051,7 @@ void nano::json_handler::election_statistics ()
|
|||
stream_utilization << std::fixed << std::setprecision (2) << utilization_percentage;
|
||||
|
||||
response_l.put ("manual", manual_count);
|
||||
response_l.put ("normal", normal_count);
|
||||
response_l.put ("priority", priority_count);
|
||||
response_l.put ("hinted", hinted_count);
|
||||
response_l.put ("optimistic", optimistic_count);
|
||||
response_l.put ("total", total_count);
|
||||
|
|
|
|||
|
|
@ -6962,7 +6962,7 @@ TEST (rpc, election_statistics)
|
|||
request.put ("action", "election_statistics");
|
||||
|
||||
auto response = wait_response (system, rpc_ctx, request);
|
||||
ASSERT_EQ ("1", response.get<std::string> ("normal"));
|
||||
ASSERT_EQ ("1", response.get<std::string> ("priority"));
|
||||
ASSERT_EQ ("0", response.get<std::string> ("hinted"));
|
||||
ASSERT_EQ ("0", response.get<std::string> ("optimistic"));
|
||||
ASSERT_EQ ("1", response.get<std::string> ("total"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue