Skip to content

Commit

Permalink
GH-2045 Fix for next_producers when no pending
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jan 15, 2024
1 parent d0a1e07 commit b5dfdd4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,17 @@ struct block_data_t {
[](const block_data_new_t&) -> const producer_authority_schedule* { return nullptr; }
}, v);
}

const producer_authority_schedule* next_producers() {
return std::visit(overloaded{
[](const block_data_legacy_t& bd) -> const producer_authority_schedule* {
return bd.head->pending_schedule_auth();
},
[](const block_data_new_t& bd) -> const producer_authority_schedule* {
return bd.head->proposer_policies.empty() ? nullptr : &bd.head->proposer_policies.begin()->second->proposer_schedule;
}
}, v);
}

const block_id_type& head_block_id() const {
return std::visit([](const auto& bd) -> const block_id_type& { return bd.head->id(); }, v);
Expand Down Expand Up @@ -4210,6 +4221,9 @@ std::optional<producer_authority_schedule> controller::proposed_producers_legacy
}

const producer_authority_schedule* controller::next_producers()const {
if( !(my->pending) )
return my->block_data.next_producers();

return my->pending->next_producers();
}

Expand Down

0 comments on commit b5dfdd4

Please sign in to comment.