From cf81e1dbb6dac456fcab0f447579941c47809e96 Mon Sep 17 00:00:00 2001 From: Gav Date: Sat, 3 Mar 2018 19:01:39 +0100 Subject: [PATCH] Deposits, not fees. --- substrate/demo/runtime/src/runtime/democracy.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/substrate/demo/runtime/src/runtime/democracy.rs b/substrate/demo/runtime/src/runtime/democracy.rs index b39b6276ef..4fd2662f68 100644 --- a/substrate/demo/runtime/src/runtime/democracy.rs +++ b/substrate/demo/runtime/src/runtime/democracy.rs @@ -96,7 +96,7 @@ pub fn launch_period() -> BlockNumber { } /// The public proposals. Unsorted. -pub fn public_props() -> Vec<(PropIndex, Proposal, Balance)> { +pub fn public_props() -> Vec<(PropIndex, Proposal)> { storage::get_or_default(PUBLIC_PROPS) } @@ -240,10 +240,15 @@ pub mod internal { .enumerate() .max_by_key(|x| locked_for((x.1).0)) { - let (prop_index, proposal, _) = public_props.swap_remove(winner_index); - storage::kill(&prop_index.to_keyed_vec(DEPOSIT_OF)); + let (prop_index, proposal) = public_props.swap_remove(winner_index); + let (deposit, depositors): (Balance, Vec) = + storage::take(&prop_index.to_keyed_vec(DEPOSIT_OF)) + .expect("depositors always exist for current proposals"); + // refund depositors + for d in &depositors { + staking::internal::set_balance(d, staking::balance(d) + deposit); + } storage::put(PUBLIC_PROPS, &public_props); - inject_referendum(now + voting_period(), proposal, VoteThreshold::SuperMajorityApprove); } }