* Improve const correctness and adhere to 'const' specifier positioning style Co-authored-by: Mario Ortiz Manero <marioortizmanero@gmail.com>
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#pragma once
|
|
#include <nano/lib/numbers.hpp>
|
|
|
|
#include <cstddef>
|
|
#include <set>
|
|
#include <vector>
|
|
|
|
namespace nano
|
|
{
|
|
class block;
|
|
class prioritization final
|
|
{
|
|
class value_type
|
|
{
|
|
public:
|
|
uint64_t time;
|
|
std::shared_ptr<nano::block> block;
|
|
bool operator< (value_type const & other_a) const;
|
|
bool operator== (value_type const & other_a) const;
|
|
};
|
|
using priority = std::set<value_type>;
|
|
std::vector<priority> buckets;
|
|
std::vector<nano::uint128_t> minimums;
|
|
void next ();
|
|
void seek ();
|
|
void populate_schedule ();
|
|
std::function<void (std::shared_ptr<nano::block>)> drop;
|
|
// Contains bucket indicies to iterate over when making the next scheduling decision
|
|
std::vector<uint8_t> schedule;
|
|
decltype (schedule)::const_iterator current;
|
|
|
|
public:
|
|
prioritization (uint64_t maximum = 250000u, std::function<void (std::shared_ptr<nano::block>)> const & drop_a = nullptr);
|
|
void push (uint64_t time, std::shared_ptr<nano::block> block);
|
|
std::shared_ptr<nano::block> top () const;
|
|
void pop ();
|
|
std::size_t size () const;
|
|
std::size_t bucket_count () const;
|
|
std::size_t bucket_size (std::size_t index) const;
|
|
bool empty () const;
|
|
void dump ();
|
|
uint64_t const maximum;
|
|
};
|
|
}
|