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

Companion: Rename pallet trait Trait to Config #2014

Merged
8 commits merged into from
Nov 30, 2020
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
fix merge
  • Loading branch information
gui1117 committed Nov 30, 2020
commit 6574dca44c484921723ca55ecebacb1769259b1b
4 changes: 2 additions & 2 deletions runtime/common/src/paras_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,13 @@ mod tests {
type Event = ();
}

impl session_info::AuthorityDiscoveryTrait for Test {
impl session_info::AuthorityDiscoveryConfig for Test {
fn authorities() -> Vec<AuthorityDiscoveryId> {
Vec::new()
}
}

impl session_info::Trait for Test { }
impl session_info::Config for Test { }

pub struct TestRandomness;

Expand Down
4 changes: 2 additions & 2 deletions runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ impl crate::inclusion::Config for Test {
type Event = TestEvent;
}

impl crate::session_info::Trait for Test { }
impl crate::session_info::Config for Test { }

impl crate::session_info::AuthorityDiscoveryTrait for Test {
impl crate::session_info::AuthorityDiscoveryConfig for Test {
fn authorities() -> Vec<AuthorityDiscoveryId> {
Vec::new()
}
Expand Down
26 changes: 13 additions & 13 deletions runtime/parachains/src/session_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ use frame_support::{
use crate::{configuration, paras, scheduler};
use sp_std::{cmp, vec::Vec};

pub trait Trait:
frame_system::Trait
+ configuration::Trait
+ paras::Trait
+ scheduler::Trait
+ AuthorityDiscoveryTrait
pub trait Config:
frame_system::Config
+ configuration::Config
+ paras::Config
+ scheduler::Config
+ AuthorityDiscoveryConfig
{
}

decl_storage! {
trait Store for Module<T: Trait> as ParaSessionInfo {
trait Store for Module<T: Config> as ParaSessionInfo {
/// The earliest session for which previous session info is stored.
EarliestStoredSession get(fn earliest_stored_session): SessionIndex;
/// Session information in a rolling window.
Expand All @@ -48,30 +48,30 @@ decl_storage! {
}

decl_error! {
pub enum Error for Module<T: Trait> { }
pub enum Error for Module<T: Config> { }
}

decl_module! {
/// The session info module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;
}
}

/// An abstraction for the authority discovery pallet
/// to help with mock testing.
pub trait AuthorityDiscoveryTrait {
pub trait AuthorityDiscoveryConfig {
/// Retrieve authority identifiers of the current and next authority set.
fn authorities() -> Vec<AuthorityDiscoveryId>;
}

impl<T: pallet_authority_discovery::Trait> AuthorityDiscoveryTrait for T {
impl<T: pallet_authority_discovery::Config> AuthorityDiscoveryConfig for T {
fn authorities() -> Vec<AuthorityDiscoveryId> {
<pallet_authority_discovery::Module<T>>::authorities()
}
}

impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Handle an incoming session change.
pub(crate) fn initializer_on_new_session(
notification: &crate::initializer::SessionChangeNotification<T::BlockNumber>
Expand All @@ -82,7 +82,7 @@ impl<T: Trait> Module<T> {
let n_parachains = <paras::Module<T>>::parachains().len() as u32;

let validators = notification.validators.clone();
let discovery_keys = <T as AuthorityDiscoveryTrait>::authorities();
let discovery_keys = <T as AuthorityDiscoveryConfig>::authorities();
// FIXME: once we store these keys: https://github.com/paritytech/polkadot/issues/1975
let approval_keys = Default::default();
let validator_groups = <scheduler::Module<T>>::validator_groups();
Expand Down