Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
kostekIV committed Jan 18, 2023
commit c4d92d18c2e81c35a0ed99bf16a325b4a2b33ca6
3 changes: 2 additions & 1 deletion pallets/aleph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ pub mod pallet {

#[pallet::storage]
#[pallet::getter(fn next_authorities)]
pub(super) type NextAuthorities<T: Config> = StorageValue<_, Vec<T::AuthorityId>, ValueQuery, DefaultNextAuthorities<T>>;
pub(super) type NextAuthorities<T: Config> =
StorageValue<_, Vec<T::AuthorityId>, ValueQuery, DefaultNextAuthorities<T>>;

#[pallet::storage]
#[pallet::getter(fn emergency_finalizer)]
Expand Down
21 changes: 12 additions & 9 deletions pallets/aleph/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use primitives::{AuthorityId, SessionIndex};
use crate::Config;
use frame_support::{
log,
sp_runtime::{RuntimeAppPublic, traits::OpaqueKeys},
sp_runtime::{traits::OpaqueKeys, RuntimeAppPublic},
};

use primitives::{AuthorityId, SessionIndex};
use sp_std::prelude::*;

use crate::Config;

/// Information provider from `pallet_session`. Loose pallet coupling via traits.
pub trait SessionInfoProvider {
fn current_session() -> SessionIndex;
}

/// Provider . Used only as default value in case of missing this information in our pallet. This can
/// happen after for the session after runtime upgrade and older ones.
/// Authorities provider, used only as default value in case of missing this information in our pallet. This can
/// happen for the session after runtime upgraded.
pub trait NextSessionAuthorityProvider<T: Config> {
fn next_authorities() -> Vec<T::AuthorityId>;
}
Expand All @@ -28,9 +28,12 @@ where
}

impl<T> NextSessionAuthorityProvider<T> for pallet_session::Pallet<T>
where T: Config + pallet_session::Config {
where
T: Config + pallet_session::Config,
{
fn next_authorities() -> Vec<T::AuthorityId> {
let next: Option<Vec<_>> = pallet_session::Pallet::<T>::queued_keys().iter()
let next: Option<Vec<_>> = pallet_session::Pallet::<T>::queued_keys()
.iter()
.map(|(_, key)| key.get(AuthorityId::ID))
.collect();

Expand All @@ -39,4 +42,4 @@ where T: Config + pallet_session::Config {
vec![]
})
}
}
}