@@ -492,24 +492,27 @@ struct building_block {
492492 uint32_t get_block_num () const { return block_num; }
493493
494494 // returns the next proposer schedule version and true if different
495- // if producers is not different then returns the current schedule version (or next schedule version)
496- // uses current building_block timestamp
495+ // if producers is not different then returns the current schedule version (or next schedule version)
497496 std::tuple<uint32_t , bool > get_next_proposer_schedule_version (const vector<producer_authority>& producers) const {
498497 assert (active_proposer_policy);
499498
500499 auto get_next_sched = [&]() -> const producer_authority_schedule& {
500+ // if there are any policies already proposed but not active yet then they are what needs to be compared
501501 if (!parent.proposer_policies .empty ()) {
502502 block_timestamp_type active_time = detail::get_next_next_round_block_time (timestamp);
503503 if (auto itr = parent.proposer_policies .find (active_time); itr != parent.proposer_policies .cend ()) {
504- // would replace so compare to prev
504+ // Same active time, a new proposer schedule will replace this entry, `next` therefore is the previous
505505 if (itr != parent.proposer_policies .begin ()) {
506506 return (--itr)->second ->proposer_schedule ;
507507 }
508+ // no previous to what will be replaced, use active
508509 return active_proposer_policy->proposer_schedule ;
509510 }
510- return (--parent.proposer_policies .end ())->second ->proposer_schedule ;
511+ // will not replace any proposed policies, use next to become active
512+ return parent.proposer_policies .begin ()->second ->proposer_schedule ;
511513 }
512514
515+ // none currently in-flight, use active
513516 return active_proposer_policy->proposer_schedule ;
514517 };
515518
0 commit comments