dncurrency/nano/node/scheduler/priority.hpp
Piotr Wójcik 81bf2230e5 Merge branch 'develop' into frontier-scan-5
# Conflicts:
#	nano/core_test/utility.cpp
#	nano/lib/thread_pool.hpp
#	nano/node/bootstrap_ascending/database_scan.cpp
#	nano/store/account.hpp
#	nano/store/iterator.hpp
2024-10-27 13:23:18 +01:00

74 lines
1.7 KiB
C++

#pragma once
#include <nano/lib/numbers.hpp>
#include <nano/node/fwd.hpp>
#include <nano/node/scheduler/bucket.hpp>
#include <condition_variable>
#include <deque>
#include <memory>
#include <string>
#include <thread>
namespace nano::scheduler
{
class buckets;
class priority_config
{
public:
// TODO: Serialization & deserialization
public:
bool enable{ true };
};
class priority final
{
public:
priority (nano::node_config &, nano::node &, nano::ledger &, nano::block_processor &, nano::active_elections &, nano::confirming_set &, nano::stats &, nano::logger &);
~priority ();
void start ();
void stop ();
/**
* Activates the first unconfirmed block of \p account_a
* @return true if account was activated
*/
bool activate (nano::secure::transaction const &, nano::account const &);
bool activate (nano::secure::transaction const &, nano::account const &, nano::account_info const &, nano::confirmation_height_info const &);
bool activate_successors (nano::secure::transaction const &, nano::block const &);
void notify ();
std::size_t size () const;
bool empty () const;
nano::container_info container_info () const;
private: // Dependencies
priority_config const & config;
nano::node & node;
nano::ledger & ledger;
nano::block_processor & block_processor;
nano::active_elections & active;
nano::confirming_set & confirming_set;
nano::stats & stats;
nano::logger & logger;
private:
void run ();
void run_cleanup ();
bool predicate () const;
bucket & find_bucket (nano::uint128_t priority);
private:
std::vector<std::unique_ptr<bucket>> buckets;
bool stopped{ false };
nano::condition_variable condition;
mutable nano::mutex mutex;
std::thread thread;
std::thread cleanup_thread;
};
}