Skip to content

Commit

Permalink
Merge pull request #332 from liberland/BLOCKCHAIN-175-multiple-refere…
Browse files Browse the repository at this point in the history
…nda-per-launch-period

BLOCKCHAIN-175 Multiple referenda per LaunchPeriod
  • Loading branch information
DorianSternVukotic authored Nov 17, 2023
2 parents ddbc46c + e421fa3 commit 71d4a16
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,28 @@ impl<T: Config> Pallet<T> {
.map_err(|_| Error::<T>::NoneWaiting.into())
}

/// Table the next waiting proposal for a vote.
fn launch_all(now: T::BlockNumber) -> DispatchResult {
loop {
if let Err(e) = Self::launch_public(now) {
if e == Error::<T>::NoneWaiting.into() {
break
}
return Err(e)
}
}
loop {
if let Err(e) = Self::launch_external(now) {
if e == Error::<T>::NoneWaiting.into() {
break
}
return Err(e)
}
}

return Ok(())
}

/// Table the waiting external proposal for a vote, if there is one.
fn launch_external(now: T::BlockNumber) -> DispatchResult {
if let Some((proposal, threshold)) = <NextExternal<T>>::take() {
Expand Down Expand Up @@ -1686,7 +1708,7 @@ impl<T: Config> Pallet<T> {
if (now % T::LaunchPeriod::get()).is_zero() {
// Errors come from the queue being empty. If the queue is not empty, it will take
// full block weight.
if Self::launch_next(now).is_ok() {
if Self::launch_all(now).is_ok() {
weight = max_block_weight;
} else {
weight.saturating_accrue(T::WeightInfo::on_initialize_base_with_launch_period(r));
Expand Down

0 comments on commit 71d4a16

Please sign in to comment.