Skip to content

Commit

Permalink
HINTED & OPTIMISTIC CONTAINER INFO
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 6, 2023
1 parent 06bd904 commit 131638a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nano/node/scheduler/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ nano::experimental::container_info nano::scheduler::component::collect_container
nano::experimental::container_info info;
info.add ("manual", manual.collect_container_info ());
info.add ("priority", priority.collect_container_info ());
info.add ("optimistic", optimistic.collect_container_info ());
info.add ("hinted", hinted.collect_container_info ());
return info;
}
15 changes: 15 additions & 0 deletions nano/node/scheduler/hinted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,14 @@ void nano::scheduler::hinted::run ()

if (!stopped)
{
lock.unlock ();

if (predicate ())
{
run_iterative ();
}

lock.lock ();
}
}
}
Expand All @@ -185,6 +189,8 @@ nano::uint128_t nano::scheduler::hinted::final_tally_threshold () const

bool nano::scheduler::hinted::cooldown (const nano::block_hash & hash)
{
nano::lock_guard<nano::mutex> lock{ mutex };

auto const now = std::chrono::steady_clock::now ();

// Check if the hash is still in the cooldown period using the hashed index
Expand All @@ -211,6 +217,15 @@ bool nano::scheduler::hinted::cooldown (const nano::block_hash & hash)
return false; // No need to cooldown
}

nano::experimental::container_info nano::scheduler::hinted::collect_container_info () const
{
nano::unique_lock<nano::mutex> lock{ mutex };

nano::experimental::container_info info;
info.put ("cooldowns", cooldowns_m);
return info;
}

/*
* hinted_config
*/
Expand Down
2 changes: 2 additions & 0 deletions nano/node/scheduler/hinted.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class hinted final
*/
void notify ();

nano::experimental::container_info collect_container_info () const;

private:
bool predicate () const;
void run ();
Expand Down
9 changes: 9 additions & 0 deletions nano/node/scheduler/optimistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ void nano::scheduler::optimistic::run_one (store::transaction const & transactio
}
}

nano::experimental::container_info nano::scheduler::optimistic::collect_container_info () const
{
nano::unique_lock<nano::mutex> lock{ mutex };

nano::experimental::container_info info;
info.put ("candidates", candidates);
return info;
}

/*
* optimistic_scheduler_config
*/
Expand Down
2 changes: 2 additions & 0 deletions nano/node/scheduler/optimistic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class optimistic final
*/
void notify ();

nano::experimental::container_info collect_container_info () const;

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

Expand Down

0 comments on commit 131638a

Please sign in to comment.