Rename pallet trait Trait to Config (#7599)

* rename Trait to Config

* add test asserting using Trait is still valid.

* fix ui tests
This commit is contained in:
Guillaume Thiolliere
2020-11-30 15:34:54 +01:00
committed by GitHub
parent dd3c84c362
commit 1cbfc9257f
200 changed files with 1767 additions and 1607 deletions
@@ -29,18 +29,18 @@ use sp_runtime::{offchain::storage::StorageValueRef, KeyTypeId};
use sp_session::MembershipProof;
use super::super::{Module as SessionModule, SessionIndex};
use super::{IdentificationTuple, ProvingTrie, Trait};
use super::{IdentificationTuple, ProvingTrie, Config};
use super::shared;
use sp_std::prelude::*;
/// A set of validators, which was used for a fixed session index.
struct ValidatorSet<T: Trait> {
struct ValidatorSet<T: Config> {
validator_set: Vec<IdentificationTuple<T>>,
}
impl<T: Trait> ValidatorSet<T> {
impl<T: Config> ValidatorSet<T> {
/// Load the set of validators for a particular session index from the off-chain storage.
///
/// If none is found or decodable given `prefix` and `session`, it will return `None`.
@@ -61,7 +61,7 @@ impl<T: Trait> ValidatorSet<T> {
/// Implement conversion into iterator for usage
/// with [ProvingTrie](super::ProvingTrie::generate_for).
impl<T: Trait> sp_std::iter::IntoIterator for ValidatorSet<T> {
impl<T: Config> sp_std::iter::IntoIterator for ValidatorSet<T> {
type Item = (T::ValidatorId, T::FullIdentification);
type IntoIter = sp_std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
@@ -74,7 +74,7 @@ impl<T: Trait> sp_std::iter::IntoIterator for ValidatorSet<T> {
/// Based on the yielded `MembershipProof` the implementer may decide what
/// to do, i.e. in case of a failed proof, enqueue a transaction back on
/// chain reflecting that, with all its consequences such as i.e. slashing.
pub fn prove_session_membership<T: Trait, D: AsRef<[u8]>>(
pub fn prove_session_membership<T: Config, D: AsRef<[u8]>>(
session_index: SessionIndex,
session_key: (KeyTypeId, D),
) -> Option<MembershipProof> {
@@ -97,7 +97,7 @@ pub fn prove_session_membership<T: Trait, D: AsRef<[u8]>>(
/// Due to re-organisation it could be that the `first_to_keep` might be less
/// than the stored one, in which case the conservative choice is made to keep records
/// up to the one that is the lesser.
pub fn prune_older_than<T: Trait>(first_to_keep: SessionIndex) {
pub fn prune_older_than<T: Config>(first_to_keep: SessionIndex) {
let derived_key = shared::LAST_PRUNE.to_vec();
let entry = StorageValueRef::persistent(derived_key.as_ref());
match entry.mutate(|current: Option<Option<SessionIndex>>| -> Result<_, ()> {
@@ -127,7 +127,7 @@ pub fn prune_older_than<T: Trait>(first_to_keep: SessionIndex) {
}
/// Keep the newest `n` items, and prune all items older than that.
pub fn keep_newest<T: Trait>(n_to_keep: usize) {
pub fn keep_newest<T: Config>(n_to_keep: usize) {
let session_index = <SessionModule<T>>::current_index();
let n_to_keep = n_to_keep as SessionIndex;
if n_to_keep < session_index {
@@ -189,8 +189,8 @@ mod tests {
#[test]
fn encode_decode_roundtrip() {
use codec::{Decode, Encode};
use super::super::super::Trait as SessionTrait;
use super::super::Trait as HistoricalTrait;
use super::super::super::Config as SessionTrait;
use super::super::Config as HistoricalTrait;
let sample = (
22u32 as <Test as SessionTrait>::ValidatorId,