configuration: refactor configuration initialization (#4569)

Refactor the configuration module's initializer_on_new_session in such a
way that it returns the configuration. This would make it inline with
other special initialization routines like `shared`'s or `paras`.

This will be useful in a following PR that will check consistency of the
configuration before setting it.
This commit is contained in:
Sergei Shulepov authored and GitHub committed 2021-12-22 16:07:44 +00:00
1 parent df2d4f313f
commit 4689ccffce
2 files changed
+57 -14

No files matched your search

@@ -221,8 +221,6 @@ impl<T: Config> Pallet<T> {
all_validators: Vec<ValidatorId>,
queued: Vec<ValidatorId>,
) {
let prev_config = <configuration::Pallet<T>>::config();
let random_seed = {
let mut buf = [0u8; 32];
// TODO: audit usage of randomness API
@@ -233,11 +231,9 @@ impl<T: Config> Pallet<T> {
buf
};
// We can't pass the new config into the thing that determines the new config,
// so we don't pass the `SessionChangeNotification` into this module.
configuration::Pallet::<T>::initializer_on_new_session(&session_index);
let new_config = <configuration::Pallet<T>>::config();
let configuration::SessionChangeOutcome { prev_config, new_config } =
configuration::Pallet::<T>::initializer_on_new_session(&session_index);
let new_config = new_config.unwrap_or_else(|| prev_config.clone());
let validators = shared::Pallet::<T>::initializer_on_new_session(
session_index,