Support Staking Payout to Any Account (#6832)

* Support staking payout to any account

* fix offences benchmarks
This commit is contained in:
Shawn Tabrizi
2020-08-26 18:26:33 +02:00
committed by GitHub
parent 1bd6082cf7
commit e69d12e76c
3 changed files with 43 additions and 12 deletions
+10 -5
View File
@@ -425,16 +425,18 @@ pub enum StakerStatus<AccountId> {
/// A destination account for payment.
#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode, RuntimeDebug)]
pub enum RewardDestination {
pub enum RewardDestination<AccountId> {
/// Pay into the stash account, increasing the amount at stake accordingly.
Staked,
/// Pay into the stash account, not increasing the amount at stake.
Stash,
/// Pay into the controller account.
Controller,
/// Pay into a specified account.
Account(AccountId),
}
impl Default for RewardDestination {
impl<AccountId> Default for RewardDestination<AccountId> {
fn default() -> Self {
RewardDestination::Staked
}
@@ -1049,7 +1051,7 @@ decl_storage! {
=> Option<StakingLedger<T::AccountId, BalanceOf<T>>>;
/// Where the reward payment should be made. Keyed by stash.
pub Payee get(fn payee): map hasher(twox_64_concat) T::AccountId => RewardDestination;
pub Payee get(fn payee): map hasher(twox_64_concat) T::AccountId => RewardDestination<T::AccountId>;
/// The map from (wannabe) validator stash key to the preferences of that validator.
pub Validators get(fn validators):
@@ -1496,7 +1498,7 @@ decl_module! {
pub fn bond(origin,
controller: <T::Lookup as StaticLookup>::Source,
#[compact] value: BalanceOf<T>,
payee: RewardDestination,
payee: RewardDestination<T::AccountId>,
) {
let stash = ensure_signed(origin)?;
@@ -1830,7 +1832,7 @@ decl_module! {
/// - Write: Payee
/// # </weight>
#[weight = 11 * WEIGHT_PER_MICROS + T::DbWeight::get().reads_writes(1, 1)]
fn set_payee(origin, payee: RewardDestination) {
fn set_payee(origin, payee: RewardDestination<T::AccountId>) {
let controller = ensure_signed(origin)?;
let ledger = Self::ledger(&controller).ok_or(Error::<T>::NotController)?;
let stash = &ledger.stash;
@@ -2489,6 +2491,9 @@ impl<T: Trait> Module<T> {
Self::update_ledger(&controller, &l);
r
}),
RewardDestination::Account(dest_account) => {
Some(T::Currency::deposit_creating(&dest_account, amount))
}
}
}