Skip to content

Commit 6f0f00a

Browse files
committed
fix session manager impl for ExistenceOf
1 parent 74220bd commit 6f0f00a

File tree

1 file changed

+15
-45
lines changed
  • substrate/frame/staking/src/pallet

1 file changed

+15
-45
lines changed

substrate/frame/staking/src/pallet/impls.rs

+15-45
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ use sp_staking::{
4747

4848
use crate::{
4949
asset, election_size_tracker::StaticTracker, log, slashing, weights::WeightInfo, ActiveEraInfo,
50-
BalanceOf, BoundedExposuresOf, EraInfo, EraPayout, ExistenceOrLegacyExposure, Exposure,
51-
Forcing, IndividualExposure, LedgerIntegrityState, MaxNominationsOf, MaxWinnersOf,
50+
BalanceOf, BoundedExposuresOf, EraInfo, EraPayout, Existence, ExistenceOrLegacyExposure,
51+
Exposure, Forcing, IndividualExposure, LedgerIntegrityState, MaxNominationsOf, MaxWinnersOf,
5252
MaxWinnersPerPageOf, Nominations, NominationsQuota, PositiveImbalanceOf, RewardDestination,
5353
SessionInterface, SnapshotStatus, StakingLedger, ValidatorPrefs, STAKING_ID,
5454
};
@@ -1728,42 +1728,23 @@ impl<T: Config> pallet_session::SessionManager<T::AccountId> for Pallet<T> {
17281728
}
17291729
}
17301730

1731-
impl<T: Config> historical::SessionManager<T::AccountId, Exposure<T::AccountId, BalanceOf<T>>>
1731+
impl<T: Config>
1732+
historical::SessionManager<T::AccountId, ExistenceOrLegacyExposure<T::AccountId, BalanceOf<T>>>
17321733
for Pallet<T>
17331734
{
17341735
fn new_session(
17351736
new_index: SessionIndex,
1736-
) -> Option<Vec<(T::AccountId, Exposure<T::AccountId, BalanceOf<T>>)>> {
1737+
) -> Option<Vec<(T::AccountId, ExistenceOrLegacyExposure<T::AccountId, BalanceOf<T>>)>> {
17371738
<Self as pallet_session::SessionManager<_>>::new_session(new_index).map(|validators| {
1738-
let current_era = CurrentEra::<T>::get()
1739-
// Must be some as a new era has been created.
1740-
.unwrap_or(0);
1741-
1742-
validators
1743-
.into_iter()
1744-
.map(|v| {
1745-
let exposure = Self::eras_stakers(current_era, &v);
1746-
(v, exposure)
1747-
})
1748-
.collect()
1739+
validators.into_iter().map(|v| (v, ExistenceOrLegacyExposure::Exists)).collect()
17491740
})
17501741
}
17511742
fn new_session_genesis(
17521743
new_index: SessionIndex,
1753-
) -> Option<Vec<(T::AccountId, Exposure<T::AccountId, BalanceOf<T>>)>> {
1744+
) -> Option<Vec<(T::AccountId, ExistenceOrLegacyExposure<T::AccountId, BalanceOf<T>>)>> {
17541745
<Self as pallet_session::SessionManager<_>>::new_session_genesis(new_index).map(
17551746
|validators| {
1756-
let current_era = CurrentEra::<T>::get()
1757-
// Must be some as a new era has been created.
1758-
.unwrap_or(0);
1759-
1760-
validators
1761-
.into_iter()
1762-
.map(|v| {
1763-
let exposure = Self::eras_stakers(current_era, &v);
1764-
(v, exposure)
1765-
})
1766-
.collect()
1747+
validators.into_iter().map(|v| (v, ExistenceOrLegacyExposure::Exists)).collect()
17671748
},
17681749
)
17691750
}
@@ -1775,25 +1756,14 @@ impl<T: Config> historical::SessionManager<T::AccountId, Exposure<T::AccountId,
17751756
}
17761757
}
17771758

1778-
impl<T: Config>
1779-
historical::SessionManager<T::AccountId, ExistenceOrLegacyExposure<T::AccountId, BalanceOf<T>>>
1780-
for Pallet<T>
1781-
{
1782-
fn new_session(
1783-
new_index: SessionIndex,
1784-
) -> Option<Vec<(T::AccountId, ExistenceOrLegacyExposure<T::AccountId, BalanceOf<T>>)>> {
1785-
<Self as pallet_session::SessionManager<_>>::new_session(new_index).map(|validators| {
1786-
validators.into_iter().map(|v| (v, ExistenceOrLegacyExposure::Exists)).collect()
1787-
})
1759+
impl<T: Config> historical::SessionManager<T::AccountId, Existence> for Pallet<T> {
1760+
fn new_session(new_index: SessionIndex) -> Option<Vec<(T::AccountId, Existence)>> {
1761+
<Self as pallet_session::SessionManager<_>>::new_session(new_index)
1762+
.map(|validators| validators.into_iter().map(|v| (v, ())).collect())
17881763
}
1789-
fn new_session_genesis(
1790-
new_index: SessionIndex,
1791-
) -> Option<Vec<(T::AccountId, ExistenceOrLegacyExposure<T::AccountId, BalanceOf<T>>)>> {
1792-
<Self as pallet_session::SessionManager<_>>::new_session_genesis(new_index).map(
1793-
|validators| {
1794-
validators.into_iter().map(|v| (v, ExistenceOrLegacyExposure::Exists)).collect()
1795-
},
1796-
)
1764+
fn new_session_genesis(new_index: SessionIndex) -> Option<Vec<(T::AccountId, Existence)>> {
1765+
<Self as pallet_session::SessionManager<_>>::new_session_genesis(new_index)
1766+
.map(|validators| validators.into_iter().map(|v| (v, ())).collect())
17971767
}
17981768
fn start_session(start_index: SessionIndex) {
17991769
<Self as pallet_session::SessionManager<_>>::start_session(start_index)

0 commit comments

Comments
 (0)