Skip to content

Commit 00b4894

Browse files
committed
payout_eligible doesn't depend on economic model; move to helper fn. Some reformatting.
1 parent bee096d commit 00b4894

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

designdocs/capacity_staking_rewards_implementation.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn stake(
5959
) -> DispatchResult {
6060
/// NEW BEHAVIOR:
6161
// if the account is new, save the new staking type
62-
// if not new and staking type is different, Error::
62+
// if not new and staking type is different, Error::CannotChangeStakingType
6363
}
6464

6565
pub fn unstake(
@@ -82,6 +82,8 @@ pub fn unstake(
8282
}
8383
```
8484
### NEW: StakingRewardsProvider - Economic Model trait
85+
This one is most likely to change, however there are certain functions that will definitely be needed.
86+
The struct and method for claiming rewards is probably going to change, but the rewards system will still need to know the `reward_pool_size` and the `staking_reward_total` for a given staker.
8587

8688
```rust
8789
use std::hash::Hash;
@@ -116,13 +118,6 @@ pub trait StakingRewardsProvider {
116118
/// Returns whether the claim passes validation. Accounts must first pass `payoutEligible` test.
117119
/// Errors: None
118120
fn validate_staking_reward_claim(account_id: AccountIdOf<T>, proof: Hash, payload: StakingRewardClaim<T>) -> bool;
119-
120-
/// Return whether `account_id` can claim a reward. Staking accounts may not claim a reward more than once
121-
/// per RewardEra, may not claim rewards before a complete RewardEra has been staked, and may not claim more rewards past
122-
/// the number of `MaxUnlockingChunks`.
123-
/// Errors:
124-
/// NotAStakingAccount if account_id has no StakingAccountDetails in storage.
125-
fn payout_eligible(account_id: AccountIdOf<T>) -> bool;
126121
}
127122
```
128123

@@ -178,7 +173,7 @@ pub struct RewardPoolInfo<T: Config> {
178173
pub type StakingRewardPool<T: Config> = <StorageMap<_, Twox64Concat, RewardEra, RewardPoolInfo<T>;
179174
```
180175

181-
#### NEW: CurrentEra
176+
### NEW: CurrentEra
182177
Incremented, like CurrentEpoch, tracks the current RewardEra number.
183178
```rust
184179
#[pallet::storage]
@@ -188,7 +183,7 @@ Incremented, like CurrentEpoch, tracks the current RewardEra number.
188183
pub type CurrentEra<T:Config> = StorageValue<_, T::RewardEra, ValueQuery>;
189184
```
190185

191-
#### NEW: Error enums
186+
### NEW: Error enums
192187
```rust
193188
pub enum Error<T> {
194189
/// ...
@@ -241,7 +236,9 @@ pub enum Error<T> {
241236
2. **change_staking_target(origin, from, to, amount)**
242237
```rust
243238
/// Change a staking account detail's target MSA Id to a new one.
244-
/// If Some(amount) is specified, that amount up to the total staking amount is retargeted. Rules for this are similar to unstaking; if `amount` would leave less than the minimum staking amount for the `from` target, the entire amount is retargeted.
239+
/// If Some(amount) is specified, that amount up to the total staking amount is retargeted.
240+
/// Rules for this are similar to unstaking; if `amount` would leave less than the minimum staking
241+
/// amount for the `from` target, the entire amount is retargeted.
245242
/// If amount is None, ALL of the total staking amount for 'from' is changed to the new target MSA Id.
246243
/// No more than T::MaxUnlockingChunks staking amounts may be retargeted within this Thawing Period.
247244
/// Each call creates one chunk.
@@ -260,8 +257,18 @@ pub fn change_staking_target(
260257
);
261258
```
262259

260+
### NEW: Capacity pallet helper function
261+
```rust
262+
/// Return whether `account_id` can claim a reward. Staking accounts may not claim a reward more than once
263+
/// per RewardEra, may not claim rewards before a complete RewardEra has been staked, and may not claim more rewards past
264+
/// the number of `MaxUnlockingChunks`.
265+
/// Errors:
266+
/// NotAStakingAccount if account_id has no StakingAccountDetails in storage.
267+
fn payout_eligible(account_id: AccountIdOf<T>) -> bool;
268+
```
269+
263270
### NEW RPC
264-
There are no custom RPCs for the Capacity pallet, so that work will need to be done.
271+
There are no custom RPCs for the Capacity pallet, so that work will need to be done first.
265272
```rust
266273
/// RPC access to the pallet function by the same name
267274
pub fn payout_eligible(account_id: AccountId) -> bool;

0 commit comments

Comments
 (0)