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

More bootstrap fixes #4699

Merged
merged 1 commit into from
Aug 11, 2024
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
10 changes: 10 additions & 0 deletions nano/node/bootstrap_ascending/account_sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ std::size_t nano::bootstrap_ascending::account_sets::blocked_size () const
return blocking.size ();
}

bool nano::bootstrap_ascending::account_sets::priority_half_full () const
{
return priorities.size () > config.priorities_max / 2;
}

bool nano::bootstrap_ascending::account_sets::blocked_half_full () const
{
return blocking.size () > config.blocking_max / 2;
}

double nano::bootstrap_ascending::account_sets::priority (nano::account const & account) const
{
if (!blocked (account))
Expand Down
2 changes: 2 additions & 0 deletions nano/node/bootstrap_ascending/account_sets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ namespace bootstrap_ascending

std::size_t priority_size () const;
std::size_t blocked_size () const;
bool priority_half_full () const;
bool blocked_half_full () const;

std::unique_ptr<nano::container_info_component> collect_container_info (std::string const & name);

Expand Down
14 changes: 9 additions & 5 deletions nano/node/bootstrap_ascending/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,20 @@ void nano::bootstrap_ascending::service::inspect (secure::transaction const & tx
break;
case nano::block_status::gap_source:
{
const auto account = block.previous ().is_zero () ? block.account_field ().value () : ledger.any.block_account (tx, block.previous ()).value ();
const auto source = block.source_field ().value_or (block.link_field ().value_or (0).as_block_hash ());
if (source == nano::block_source::bootstrap)
{
const auto account = block.previous ().is_zero () ? block.account_field ().value () : ledger.any.block_account (tx, block.previous ()).value ();
const auto source_hash = block.source_field ().value_or (block.link_field ().value_or (0).as_block_hash ());

// Mark account as blocked because it is missing the source block
accounts.block (account, source);
// Mark account as blocked because it is missing the source block
accounts.block (account, source_hash);
}
}
break;
case nano::block_status::gap_previous:
{
if (source == nano::block_source::live)
// Prevent live traffic from evicting accounts from the priority list
if (source == nano::block_source::live && !accounts.priority_half_full () && !accounts.blocked_half_full ())
{
if (block.type () == block_type::state)
{
Expand Down
Loading