Skip to content

Commit

Permalink
Bootstrap fixes (#4699)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev authored and clemahieu committed Aug 11, 2024
1 parent 9de0421 commit 7b25a54
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
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

0 comments on commit 7b25a54

Please sign in to comment.