Rename validators to select_validators

This commit is contained in:
Luke Parker
2023-10-11 17:23:09 -04:00
parent 2401266374
commit f692047b8b
2 changed files with 5 additions and 8 deletions

View File

@@ -158,17 +158,14 @@ pub mod pallet {
// then we wait until the session ends then get a call to end_session(i) and so on. // then we wait until the session ends then get a call to end_session(i) and so on.
impl<T: Config> SessionManager<T::ValidatorId> for Pallet<T> { impl<T: Config> SessionManager<T::ValidatorId> for Pallet<T> {
fn new_session(_new_index: u32) -> Option<Vec<T::ValidatorId>> { fn new_session(_new_index: u32) -> Option<Vec<T::ValidatorId>> {
// Don't call new_session multiple times on genesis
// TODO: Will this cause pallet_session::Pallet::current_index to desync from validator-sets?
if frame_system::Pallet::<T>::block_number() > 1u32.into() {
VsPallet::<T>::new_session(); VsPallet::<T>::new_session();
}
// TODO: Where do we return their stake? // TODO: Where do we return their stake?
Some(VsPallet::<T>::validators(NetworkId::Serai)) Some(VsPallet::<T>::select_validators(NetworkId::Serai))
} }
fn new_session_genesis(_: u32) -> Option<Vec<T::ValidatorId>> { fn new_session_genesis(_: u32) -> Option<Vec<T::ValidatorId>> {
Some(VsPallet::<T>::validators(NetworkId::Serai)) // TODO: Because we don't call new_session here, we don't emit NewSet { Serai, session: 1 }
Some(VsPallet::<T>::select_validators(NetworkId::Serai))
} }
fn end_session(_end_index: u32) {} fn end_session(_end_index: u32) {}

View File

@@ -418,7 +418,7 @@ pub mod pallet {
} }
} }
pub fn validators(network: NetworkId) -> Vec<Public> { pub fn select_validators(network: NetworkId) -> Vec<Public> {
Self::participants(network).into() Self::participants(network).into()
} }