From 50648b27ee71c4b924c27c368e070d14d8034f99 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Fri, 8 Sep 2023 12:27:57 +0100 Subject: [PATCH] Removing buckets::schedule as it's confusing and unnecessary. --- nano/node/scheduler/buckets.cpp | 24 +++++++----------------- nano/node/scheduler/buckets.hpp | 6 +----- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/nano/node/scheduler/buckets.cpp b/nano/node/scheduler/buckets.cpp index 59344f7b72..c033f6f6ca 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]->empty () && i < n; ++i) + for (std::size_t i = 0, n = buckets_m.size (); (*current)->empty () && 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,7 +86,7 @@ void nano::scheduler::buckets::push (uint64_t time, std::shared_ptr std::shared_ptr nano::scheduler::buckets::top () const { debug_assert (!empty ()); - auto result = buckets_m[*current]->top (); + auto result = (*current)->top (); return result; } @@ -104,7 +94,7 @@ std::shared_ptr nano::scheduler::buckets::top () const void nano::scheduler::buckets::pop () { debug_assert (!empty ()); - auto & bucket = buckets_m[*current]; + auto & bucket = *current; bucket->pop (); seek (); } @@ -145,7 +135,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);