mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-22 22:01:08 +00:00
Pallet AURA: remove pallet::getter macro and write the corresponding code (#3350)
Removed the `pallet::getter` macro call from storage type definitions and added the corresponding implementations directly. fixes #3330 polkadot address: 14JzTPPUd8x8phKi8qLxHgNTnTMg6DUukCLXoWprejkaHXPz --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -161,16 +161,14 @@ pub mod pallet {
|
||||
|
||||
/// The current authority set.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn authorities)]
|
||||
pub(super) type Authorities<T: Config> =
|
||||
pub type Authorities<T: Config> =
|
||||
StorageValue<_, BoundedVec<T::AuthorityId, T::MaxAuthorities>, ValueQuery>;
|
||||
|
||||
/// The current slot of this block.
|
||||
///
|
||||
/// This will be set in `on_initialize`.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn current_slot)]
|
||||
pub(super) type CurrentSlot<T: Config> = StorageValue<_, Slot, ValueQuery>;
|
||||
pub type CurrentSlot<T: Config> = StorageValue<_, Slot, ValueQuery>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[derive(frame_support::DefaultNoBound)]
|
||||
@@ -318,7 +316,7 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
|
||||
// instant changes
|
||||
if changed {
|
||||
let next_authorities = validators.map(|(_, k)| k).collect::<Vec<_>>();
|
||||
let last_authorities = Self::authorities();
|
||||
let last_authorities = Authorities::<T>::get();
|
||||
if last_authorities != next_authorities {
|
||||
if next_authorities.len() as u32 > T::MaxAuthorities::get() {
|
||||
log::warn!(
|
||||
@@ -374,7 +372,7 @@ impl<T: Config, Inner: FindAuthor<u32>> FindAuthor<T::AuthorityId>
|
||||
{
|
||||
let i = Inner::find_author(digests)?;
|
||||
|
||||
let validators = <Pallet<T>>::authorities();
|
||||
let validators = Authorities::<T>::get();
|
||||
validators.get(i as usize).cloned()
|
||||
}
|
||||
}
|
||||
@@ -384,7 +382,7 @@ pub type AuraAuthorId<T> = FindAccountFromAuthorIndex<T, Pallet<T>>;
|
||||
|
||||
impl<T: Config> IsMember<T::AuthorityId> for Pallet<T> {
|
||||
fn is_member(authority_id: &T::AuthorityId) -> bool {
|
||||
Self::authorities().iter().any(|id| id == authority_id)
|
||||
Authorities::<T>::get().iter().any(|id| id == authority_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use crate::mock::{build_ext_and_execute_test, Aura, MockDisabledValidators, System};
|
||||
use super::pallet;
|
||||
use crate::mock::{build_ext_and_execute_test, Aura, MockDisabledValidators, System, Test};
|
||||
use codec::Encode;
|
||||
use frame_support::traits::OnInitialize;
|
||||
use sp_consensus_aura::{Slot, AURA_ENGINE_ID};
|
||||
@@ -28,8 +29,8 @@ use sp_runtime::{Digest, DigestItem};
|
||||
#[test]
|
||||
fn initial_values() {
|
||||
build_ext_and_execute_test(vec![0, 1, 2, 3], || {
|
||||
assert_eq!(Aura::current_slot(), 0u64);
|
||||
assert_eq!(Aura::authorities().len(), Aura::authorities_len());
|
||||
assert_eq!(pallet::CurrentSlot::<Test>::get(), 0u64);
|
||||
assert_eq!(pallet::Authorities::<Test>::get().len(), Aura::authorities_len());
|
||||
assert_eq!(Aura::authorities_len(), 4);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user