diff --git a/nano/node/scheduler/buckets.cpp b/nano/node/scheduler/buckets.cpp index 60ec50110f..e50dccba34 100644 --- a/nano/node/scheduler/buckets.cpp +++ b/nano/node/scheduler/buckets.cpp @@ -9,9 +9,9 @@ void nano::scheduler::buckets::next () { ++current; - if (current == schedule.end ()) + if (current == buckets_m.end ()) { - current = schedule.begin (); + current = buckets_m.begin (); } } @@ -19,21 +19,12 @@ void nano::scheduler::buckets::next () void nano::scheduler::buckets::seek () { next (); - for (std::size_t i = 0, n = schedule.size (); !buckets_m[*current]->available () && i < n; ++i) + for (std::size_t i = 0, n = buckets_m.size (); !(*current)->available () && i < n; ++i) { next (); } } -/** Initialise the schedule vector */ -void nano::scheduler::buckets::populate_schedule () -{ - for (auto i = 0; i < buckets_m.size (); ++i) - { - schedule.push_back (i); - } -} - /** * Prioritization constructor, construct a container containing approximately 'maximum' number of blocks. * @param maximum number of blocks that this container can hold, this is a soft and approximate limit. @@ -63,8 +54,7 @@ nano::scheduler::buckets::buckets (uint64_t maximum) : { buckets_m.push_back (std::make_unique (bucket_max)); } - populate_schedule (); - current = schedule.begin (); + current = buckets_m.begin (); } nano::scheduler::buckets::~buckets () @@ -96,8 +86,8 @@ void nano::scheduler::buckets::push (uint64_t time, std::shared_ptr std::shared_ptr nano::scheduler::buckets::top () const { debug_assert (!empty ()); - debug_assert (buckets_m[*current]->available ()); - auto result = buckets_m[*current]->top (); + debug_assert ((*current)->available ()); + auto result = (*current)->top (); return result; } @@ -105,8 +95,8 @@ std::shared_ptr nano::scheduler::buckets::top () const void nano::scheduler::buckets::pop () { debug_assert (!empty ()); - debug_assert (buckets_m[*current]->available ()); - auto & bucket = buckets_m[*current]; + debug_assert ((*current)->available ()); + auto & bucket = *current; bucket->pop (); seek (); } @@ -147,7 +137,7 @@ void nano::scheduler::buckets::dump () const { bucket->dump (); } - std::cerr << "current: " << std::to_string (*current) << '\n'; + std::cerr << "current: " << current - buckets_m.begin () << '\n'; } std::unique_ptr nano::scheduler::buckets::collect_container_info (std::string const & name) diff --git a/nano/node/scheduler/buckets.hpp b/nano/node/scheduler/buckets.hpp index 0c4b745ac8..967b4408f7 100644 --- a/nano/node/scheduler/buckets.hpp +++ b/nano/node/scheduler/buckets.hpp @@ -33,18 +33,14 @@ class buckets final * the container writes a block to the lowest indexed bucket that has balance larger than the bucket's minimum value */ std::deque minimums; - /** Contains bucket indicies to iterate over when making the next scheduling decision */ - std::deque schedule; - /** index of bucket to read next */ - decltype (schedule)::const_iterator current; + decltype (buckets_m)::const_iterator current; /** maximum number of blocks in whole container, each bucket's maximum is maximum / bucket_number */ uint64_t const maximum; void next (); void seek (); - void populate_schedule (); public: buckets (uint64_t maximum = 250000u);