Skip to content

Commit 2059dc9

Browse files
committed
Documentation
1 parent 9eb281b commit 2059dc9

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

substrate/frame/conviction-voting/src/traits.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ use frame_support::dispatch::DispatchResult;
2323
use scale_info::TypeInfo;
2424
use sp_runtime::RuntimeDebug;
2525

26+
27+
/// Represents the differents states of a referendum.
28+
/// None: The referendum is not started.
29+
/// Ongoing: The referendum is ongoing.
30+
/// Completed: The referendum is finished.
2631
#[derive(
2732
Encode,
2833
Decode,
@@ -45,12 +50,10 @@ pub trait VotingHooks<AccountId, Index, Balance> {
4550
fn on_vote(who: &AccountId, ref_index: Index, vote: AccountVote<Balance>) -> DispatchResult;
4651

4752
// Called when removed vote is executed.
48-
// is_finished indicates the state of the referendum = None if referendum is cancelled, Ongoing
49-
// if referendum is ongoing and Completed when finished.
5053
fn on_remove_vote(who: &AccountId, ref_index: Index, status: Status);
5154

52-
// Called when removed vote is executed and voter lost the direction to possibly lock some
53-
// balance. Can return an amount that should be locked for the conviction time.
55+
// Called when a vote is unsuccessful.
56+
// Returns the amount of locked balance, which is `None` in the default implementation.
5457
fn lock_balance_on_unsuccessful_vote(who: &AccountId, ref_index: Index) -> Option<Balance>;
5558

5659
/// Will be called by benchmarking before calling `on_vote` in a benchmark.

substrate/frame/conviction-voting/src/vote.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ pub enum AccountVote<Balance> {
9292
SplitAbstain { aye: Balance, nay: Balance, abstain: Balance },
9393
}
9494

95+
96+
/// present the conditions under which an account's Funds are locked after a voting action.
97+
/// - `Status(bool)`: Implement a locking period if the referendum passed and `bool` is `true`.
98+
/// - `Always`: lock the funds regardless of the outcome of the referendum.
9599
#[derive(
96100
Copy,
97101
Clone,
@@ -106,7 +110,7 @@ pub enum LockedIf {
106110

107111
impl<Balance: Saturating> AccountVote<Balance> {
108112
/// Returns `Some` of the lock periods that the account is locked for, assuming that the
109-
/// referendum passed iff `approved` is `true`.
113+
/// referendum passed if `approved` is `true`.
110114
pub fn locked_if(self, approved: LockedIf) -> Option<(u32, Balance)> {
111115
// winning side: can only be removed after the lock period ends.
112116
match (self, approved) {

0 commit comments

Comments
 (0)