Skip to content

Commit

Permalink
Revert "Rewrite optimistic scheduler in terms of ledger sets and add …
Browse files Browse the repository at this point in the history
…ledger set height(account) overload."

This reverts commit 9512140.

# Conflicts:
#	nano/node/backlog_population.cpp
#	nano/node/node.cpp
  • Loading branch information
pwojcikdev committed May 22, 2024
1 parent 8c3cf40 commit 2dd6605
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 8 additions & 9 deletions nano/node/scheduler/optimistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,30 @@ void nano::scheduler::optimistic::notify ()
condition.notify_all ();
}

bool nano::scheduler::optimistic::activate_predicate (nano::secure::transaction const & transaction, nano::account const & account) const
bool nano::scheduler::optimistic::activate_predicate (const nano::account_info & account_info, const nano::confirmation_height_info & conf_info) const
{
auto unconfirmed_height = ledger.any.account_height (transaction, account);
auto confirmed_height = ledger.confirmed.account_height (transaction, account);
// Account with nothing confirmed yet
if (confirmed_height == 0)
// Chain with a big enough gap between account frontier and confirmation frontier
if (account_info.block_count - conf_info.height > config.gap_threshold)
{
return true;
}
// Chain with a big enough gap between account frontier and confirmation frontier
if (unconfirmed_height - confirmed_height > config.gap_threshold)
// Account with nothing confirmed yet
if (conf_info.height == 0)
{
return true;
}
return false;
}

bool nano::scheduler::optimistic::activate (nano::secure::transaction const & transaction, nano::account const & account)
bool nano::scheduler::optimistic::activate (const nano::account & account, const nano::account_info & account_info, const nano::confirmation_height_info & conf_info)
{
if (!config.enabled)
{
return false;
}

if (activate_predicate (transaction, account))
debug_assert (account_info.block_count >= conf_info.height);
if (activate_predicate (account_info, conf_info))
{
{
nano::lock_guard<nano::mutex> lock{ mutex };
Expand Down
4 changes: 2 additions & 2 deletions nano/node/scheduler/optimistic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class optimistic final
/**
* Called from backlog population to process accounts with unconfirmed blocks
*/
bool activate (nano::secure::transaction const & transaction, nano::account const & account);
bool activate (nano::account const &, nano::account_info const &, nano::confirmation_height_info const &);

/**
* Notify about changes in AEC vacancy
Expand All @@ -70,7 +70,7 @@ class optimistic final
std::unique_ptr<container_info_component> collect_container_info (std::string const & name) const;

private:
bool activate_predicate (nano::secure::transaction const & transaction, nano::account const & account) const;
bool activate_predicate (nano::account_info const &, nano::confirmation_height_info const &) const;

bool predicate () const;
void run ();
Expand Down

0 comments on commit 2dd6605

Please sign in to comment.