mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
move generics of election trait to associated types (#10475)
* move generics of election trait to associated types * fix doctest
This commit is contained in:
@@ -139,7 +139,7 @@
|
||||
//! To generate an emergency solution, one must only provide one argument: [`Supports`]. This is
|
||||
//! essentially a collection of elected winners for the election, and voters who support them. The
|
||||
//! supports can be generated by any means. In the simplest case, it could be manual. For example,
|
||||
//! in the case of massive network failure or misbehaviour, [`Config::ForceOrigin`] might decide to
|
||||
//! in the case of massive network failure or misbehavior, [`Config::ForceOrigin`] might decide to
|
||||
//! select only a small number of emergency winners (which would greatly restrict the next validator
|
||||
//! set, if this pallet is used with `pallet-staking`). If the failure is for other technical
|
||||
//! reasons, then a simple and safe way to generate supports is using the staking-miner binary
|
||||
@@ -286,10 +286,7 @@ pub type SolutionTargetIndexOf<T> = <SolutionOf<T> as NposSolution>::TargetIndex
|
||||
/// The accuracy of the election, when submitted from offchain. Derived from [`SolutionOf`].
|
||||
pub type SolutionAccuracyOf<T> = <SolutionOf<T> as NposSolution>::Accuracy;
|
||||
/// The fallback election type.
|
||||
pub type FallbackErrorOf<T> = <<T as crate::Config>::Fallback as ElectionProvider<
|
||||
<T as frame_system::Config>::AccountId,
|
||||
<T as frame_system::Config>::BlockNumber,
|
||||
>>::Error;
|
||||
pub type FallbackErrorOf<T> = <<T as crate::Config>::Fallback as ElectionProvider>::Error;
|
||||
|
||||
/// Configuration for the benchmarks of the pallet.
|
||||
pub trait BenchmarkingConfig {
|
||||
@@ -312,7 +309,9 @@ pub trait BenchmarkingConfig {
|
||||
/// A fallback implementation that transitions the pallet to the emergency phase.
|
||||
pub struct NoFallback<T>(sp_std::marker::PhantomData<T>);
|
||||
|
||||
impl<T: Config> ElectionProvider<T::AccountId, T::BlockNumber> for NoFallback<T> {
|
||||
impl<T: Config> ElectionProvider for NoFallback<T> {
|
||||
type AccountId = T::AccountId;
|
||||
type BlockNumber = T::BlockNumber;
|
||||
type DataProvider = T::DataProvider;
|
||||
type Error = &'static str;
|
||||
|
||||
@@ -654,7 +653,10 @@ pub mod pallet {
|
||||
type MinerMaxLength: Get<u32>;
|
||||
|
||||
/// Something that will provide the election data.
|
||||
type DataProvider: ElectionDataProvider<Self::AccountId, Self::BlockNumber>;
|
||||
type DataProvider: ElectionDataProvider<
|
||||
AccountId = Self::AccountId,
|
||||
BlockNumber = Self::BlockNumber,
|
||||
>;
|
||||
|
||||
/// The solution type.
|
||||
type Solution: codec::Codec
|
||||
@@ -669,8 +671,8 @@ pub mod pallet {
|
||||
|
||||
/// Configuration for the fallback
|
||||
type Fallback: ElectionProvider<
|
||||
Self::AccountId,
|
||||
Self::BlockNumber,
|
||||
AccountId = Self::AccountId,
|
||||
BlockNumber = Self::BlockNumber,
|
||||
DataProvider = Self::DataProvider,
|
||||
>;
|
||||
|
||||
@@ -818,7 +820,7 @@ pub mod pallet {
|
||||
// NOTE that this pallet does not really need to enforce this in runtime. The
|
||||
// solution cannot represent any voters more than `LIMIT` anyhow.
|
||||
assert_eq!(
|
||||
<T::DataProvider as ElectionDataProvider<T::AccountId, T::BlockNumber>>::MAXIMUM_VOTES_PER_VOTER,
|
||||
<T::DataProvider as ElectionDataProvider>::MAXIMUM_VOTES_PER_VOTER,
|
||||
<SolutionOf<T> as NposSolution>::LIMIT as u32,
|
||||
);
|
||||
}
|
||||
@@ -1492,7 +1494,9 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> ElectionProvider<T::AccountId, T::BlockNumber> for Pallet<T> {
|
||||
impl<T: Config> ElectionProvider for Pallet<T> {
|
||||
type AccountId = T::AccountId;
|
||||
type BlockNumber = T::BlockNumber;
|
||||
type Error = ElectionError<T>;
|
||||
type DataProvider = T::DataProvider;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user