Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bandwidth considerations following election refactor #2646

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions nano/node/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ bool nano::election::state_change (nano::election::state_t expected_a, nano::ele

void nano::election::send_confirm_req (nano::confirmation_solicitor & solicitor_a)
{
if (last_req + std::chrono::seconds (15) < std::chrono::steady_clock::now ())
if (base_latency () * 5 < std::chrono::steady_clock::now () - last_req)
{
if (!solicitor_a.add (*this))
{
Expand Down Expand Up @@ -181,14 +181,7 @@ void nano::election::transition_active ()

void nano::election::transition_active_impl ()
{
if (!state_change (nano::election::state_t::idle, nano::election::state_t::active))
{
if (base_latency () * 5 < std::chrono::steady_clock::now () - last_block)
{
last_block = std::chrono::steady_clock::now ();
node.network.flood_block (status.winner);
}
}
state_change (nano::election::state_t::idle, nano::election::state_t::active);
}

bool nano::election::idle () const
Expand Down Expand Up @@ -247,7 +240,7 @@ void nano::election::activate_dependencies ()

void nano::election::broadcast_block (nano::confirmation_solicitor & solicitor_a)
{
if (base_latency () * 5 < std::chrono::steady_clock::now () - last_block)
if (base_latency () * 20 < std::chrono::steady_clock::now () - last_block)
{
if (!solicitor_a.broadcast (*this))
{
Expand Down
5 changes: 2 additions & 3 deletions nano/node/election.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ class election final : public std::enable_shared_from_this<nano::election>
expired_unconfirmed
};
static int constexpr passive_duration_factor = 5;
static int constexpr active_duration_factor = 20;
static int constexpr active_duration_factor = 30;
static int constexpr confirmed_duration_factor = 10;
static int constexpr confirmed_duration_factor_saturated = 1;
std::atomic<nano::election::state_t> state_m = { state_t::idle };

// Protects state_start, last_vote and last_block
std::mutex timepoints_mutex;
std::chrono::steady_clock::time_point state_start = { std::chrono::steady_clock::now () };
std::chrono::steady_clock::time_point last_vote = { std::chrono::steady_clock::time_point () };
std::chrono::steady_clock::time_point last_block = { std::chrono::steady_clock::time_point () };
std::chrono::steady_clock::time_point last_block = { std::chrono::steady_clock::now () };
std::chrono::steady_clock::time_point last_req = { std::chrono::steady_clock::time_point () };

bool valid_change (nano::election::state_t, nano::election::state_t) const;
Expand Down