Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Remove unused code from pallet-staking
Browse files Browse the repository at this point in the history
  • Loading branch information
MRamanenkau committed May 17, 2023
1 parent 1e591a7 commit 74029a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
39 changes: 2 additions & 37 deletions frame/staking/src/pallet/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
// limitations under the License.

//! Implementations for the Staking FRAME Pallet.
use frame_election_provider_support::{
data_provider, ElectionDataProvider, ElectionProvider, ScoreProvider, SortedListProvider,
Supports, VoteWeight, VoterOf,
};
use frame_support::{
decl_event, decl_module, decl_storage,
log::{error, info, warn},
pallet_prelude::*,
traits::{
Currency, CurrencyToVote, Defensive, EstimateNextNewSession, Get, Imbalance,
Expand All @@ -45,7 +44,7 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*};
use crate::{
log, slashing, weights::WeightInfo, ActiveEraInfo, BalanceOf, EraPayout, Exposure, ExposureOf,
Forcing, IndividualExposure, Nominations, PositiveImbalanceOf, RewardDestination,
SessionInterface, StakingLedger, ValidatorPrefs, EraDacRewardPoints,
SessionInterface, StakingLedger, ValidatorPrefs,
};

use super::{pallet::*, STAKING_ID};
Expand Down Expand Up @@ -628,40 +627,6 @@ impl<T: Config> Pallet<T> {
era_rewards.total += points;
}
});
let erasRewardPoints = <ErasRewardPoints<T>>::get(active_era.index);
}
}

pub fn reward_by_ids2(validators_points: impl IntoIterator<Item = (T::AccountId, u32)>) {
if let Some(active_era) = Self::active_era() {
<ErasDacRewardPoints<T>>::mutate(active_era.index, |era_rewards| {
let mut p = EraDacRewardPoints {
total: era_rewards.total.clone(),
individual: era_rewards.individual.clone(),
};
for (validator, points) in validators_points.into_iter() {
*p.individual.entry(validator).or_default() += points;
p.total += points;
}
return p;
});
let dacRewardPoints = <ErasDacRewardPoints<T>>::get(active_era.index);
}
}

pub fn get_reward_points(validators_points: impl IntoIterator<Item = (T::AccountId, u32)>) {
info!("Hello from get_reward_points");
if let Some(active_era) = Self::active_era() {
<ErasDacRewardPoints<T>>::mutate(active_era.index, |era_rewards| {
for (validator, points) in validators_points.into_iter() {
// info!("validator: {:?}, points: {:?}", validator, points);
// *era_rewards.individual.entry(validator).or_default() += points;
info!("reading era_rewards.total: {:?}", era_rewards.total);
// era_rewards.total += points;
}
});
let dacRewardPoints = <ErasDacRewardPoints<T>>::get(active_era.index);
info!("reading dacRewardPoints: {:?}", dacRewardPoints);
}
}

Expand Down
13 changes: 4 additions & 9 deletions frame/staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ mod impls;
pub use impls::*;

use crate::{
slashing, weights::WeightInfo, ActiveEraInfo, BalanceOf, EraDacRewardPoints, EraPayout,
EraRewardPoints, Exposure, Forcing, MaxUnlockingChunks, NegativeImbalanceOf, Nominations,
PositiveImbalanceOf, Releases, RewardDestination, SessionInterface, StakingLedger,
UnappliedSlash, UnlockChunk, ValidatorPrefs,
slashing, weights::WeightInfo, ActiveEraInfo, BalanceOf, EraPayout, EraRewardPoints, Exposure,
Forcing, MaxUnlockingChunks, NegativeImbalanceOf, Nominations, PositiveImbalanceOf, Releases,
RewardDestination, SessionInterface, StakingLedger, UnappliedSlash, UnlockChunk,
ValidatorPrefs,
};

const STAKING_ID: LockIdentifier = *b"staking ";
Expand Down Expand Up @@ -399,11 +399,6 @@ pub mod pallet {
pub type ErasRewardPoints<T: Config> =
StorageMap<_, Twox64Concat, EraIndex, EraRewardPoints<T::AccountId>, ValueQuery>;

#[pallet::storage]
#[pallet::getter(fn eras_dac_reward_points)]
pub type ErasDacRewardPoints<T: Config> =
StorageMap<_, Twox64Concat, EraIndex, EraDacRewardPoints<T::AccountId>, ValueQuery>;

/// The total amount staked for the last `HISTORY_DEPTH` eras.
/// If total hasn't been set or has been removed then 0 stake is returned.
#[pallet::storage]
Expand Down

0 comments on commit 74029a2

Please sign in to comment.