fn bake_referendum(
		now: T::BlockNumber,
		index: ReferendumIndex,
		info: ReferendumInfo<T::BlockNumber, T::Proposal>,
	) -> Result {
		let (approve, against, capital) = Self::tally(index);
		let total_issuance = T::Currency::total_issuance();
		let approved = info.threshold.approved(approve, against, capital, total_issuance);
		let lock_period = Self::public_delay();

		// Logic defined in https://www.slideshare.net/gavofyork/governance-in-polkadot-poc3
		// Essentially, we extend the lock-period of the coins behind the winning votes to be the
		// vote strength times the public delay period from now.
		for (a, vote) in Self::voters_for(index).into_iter()
			.map(|a| (a.clone(), Self::vote_of((index, a))))
			// ^^^ defensive only: all items come from `voters`;
			// for an item to be in `voters` there must be a vote registered; qed
			.filter(|&(_, vote)| vote.is_aye() == approved)	// Just the winning coins
		{
			// now plus: the base lock period multiplied by the number of periods this voter offered to
			// lock should they win...
			let locked_until = now + lock_period * T::BlockNumber::sa((vote.multiplier()) as u64);
			// ...extend their bondage until at least then.
			T::Currency::extend_lock(
				DEMOCRACY_ID,
				&a,
				Bounded::max_value(),
				locked_until,
				WithdrawReason::Transfer.into()
			);
		}

		Self::clear_referendum(index);
		if approved {
			Self::deposit_event(RawEvent::Passed(index));
			if info.delay.is_zero() {
				Self::enact_proposal(info.proposal, index);
			} else {
				<DispatchQueue<T>>::mutate(now + info.delay, |q| q.push(Some((info.proposal, index))));
			}
		} else {
			Self::deposit_event(RawEvent::NotPassed(index));
		}
		<NextTally<T>>::put(index + 1);

		Ok(())
	}
/// Tally the votes for a referendum, apply appropriate currency locks to voters, clear the
/// referendum from the table, and either enact the referendum or add it to `DispatchQueue`.
Tally the votes for a referendum, apply appropriate currency locks to voters, clear the
referendum from the table, and either enact the referendum or add it to `DispatchQueue`.
Tally the votes for a referendum apply appropriate currency locks to voters clear the referendum from the table and either enact the referendum or add it to ` DispatchQueue ` .
fn bake_referendum(
		now: T::BlockNumber,
		index: ReferendumIndex,
		info: ReferendumInfo<T::BlockNumber, T::Proposal>,
	) -> Result {
		let (approve, against, capital) = Self::tally(index);
		let total_issuance = T::Currency::total_issuance();
		let approved = info.threshold.approved(approve, against, capital, total_issuance);
		let lock_period = Self::public_delay();
		// Logic defined in https://www.slideshare.net/gavofyork/governance-in-polkadot-poc3
		// Essentially, we extend the lock-period of the coins behind the winning votes to be the
		// vote strength times the public delay period from now.
		for (a, vote) in Self::voters_for(index).into_iter()
			.map(|a| (a.clone(), Self::vote_of((index, a))))
			// ^^^ defensive only: all items come from `voters`;
			// for an item to be in `voters` there must be a vote registered; qed
			.filter(|&(_, vote)| vote.is_aye() == approved)	// Just the winning coins
		{
			// now plus: the base lock period multiplied by the number of periods this voter offered to
			// lock should they win...
			let locked_until = now + lock_period * T::BlockNumber::sa((vote.multiplier()) as u64);
			// ...extend their bondage until at least then.
			T::Currency::extend_lock(
				DEMOCRACY_ID,
				&a,
				Bounded::max_value(),
				locked_until,
				WithdrawReason::Transfer.into()
			);
		}
		Self::clear_referendum(index);
		if approved {
			Self::deposit_event(RawEvent::Passed(index));
			if info.delay.is_zero() {
				Self::enact_proposal(info.proposal, index);
			} else {
				<DispatchQueue<T>>::mutate(now + info.delay, |q| q.push(Some((info.proposal, index))));
			}
		} else {
			Self::deposit_event(RawEvent::NotPassed(index));
		}
		<NextTally<T>>::put(index + 1);
		Ok(())
	}
fn bake_referendum ( now : T :: BlockNumber , index : ReferendumIndex , info : ReferendumInfo < T :: BlockNumber , T :: Proposal > , ) -> Result { let ( approve , against , capital ) = Self :: tally ( index ) ; let total_issuance = T :: Currency :: total_issuance ( ) ; let approved = info . threshold . approved ( approve , against , capital , total_issuance ) ; let lock_period = Self :: public_delay ( ) ; // Logic defined in https://www.slideshare.net/gavofyork/governance-in-polkadot-poc3 // Essentially, we extend the lock-period of the coins behind the winning votes to be the // vote strength times the public delay period from now. for ( a , vote ) in Self :: voters_for ( index ) . into_iter ( ) . map ( | a | ( a . clone ( ) , Self :: vote_of ( ( index , a ) ) ) ) // ^^^ defensive only: all items come from `voters`; // for an item to be in `voters` there must be a vote registered; qed . filter ( | & ( _ , vote ) | vote . is_aye ( ) == approved ) // Just the winning coins { // now plus: the base lock period multiplied by the number of periods this voter offered to // lock should they win... let locked_until = now + lock_period * T :: BlockNumber :: sa ( ( vote . multiplier ( ) ) as u64 ) ; // ...extend their bondage until at least then. T :: Currency :: extend_lock ( DEMOCRACY_ID , & a , Bounded :: max_value ( ) , locked_until , WithdrawReason :: Transfer . into ( ) ) ; } Self :: clear_referendum ( index ) ; if approved { Self :: deposit_event ( RawEvent :: Passed ( index ) ) ; if info . delay . is_zero ( ) { Self :: enact_proposal ( info . proposal , index ) ; } else { < DispatchQueue < T > > :: mutate ( now + info . delay , | q | q . push ( Some ( ( info . proposal , index ) ) ) ) ; } } else { Self :: deposit_event ( RawEvent :: NotPassed ( index ) ) ; } < NextTally < T > > :: put ( index + 1 ) ; Ok ( ( ) ) }
Tally the votes for a referendum, apply appropriate currency locks to voters, clear the
referendum from the table, and either enact the referendum or add it to `DispatchQueue`.
Tally the votes for a referendum apply appropriate currency locks to voters clear the referendum from the table and either enact the referendum or add it to ` DispatchQueue ` .
now
T::BlockNumber
index
ReferendumIndex
info
ReferendumInfo<T::BlockNumber, T::Proposal>
now
T::BlockNumber
index
ReferendumIndex
info
ReferendumInfo<T::BlockNumber, T::Proposal>