aura: export change_authorities and initialize_authorities (#11468)

* aura: export change_authorities and initialize_authorities

* add docs

* fix docs
This commit is contained in:
yjh
2022-06-02 17:03:49 +08:00
committed by GitHub
parent a084dd684f
commit ba96e8a8f4
+11 -2
View File
@@ -146,7 +146,11 @@ pub mod pallet {
}
impl<T: Config> Pallet<T> {
fn change_authorities(new: WeakBoundedVec<T::AuthorityId, T::MaxAuthorities>) {
/// Change authorities.
///
/// The storage will be applied immediately.
/// And aura consensus log will be appended to block's log.
pub fn change_authorities(new: WeakBoundedVec<T::AuthorityId, T::MaxAuthorities>) {
<Authorities<T>>::put(&new);
let log = DigestItem::Consensus(
@@ -156,7 +160,12 @@ impl<T: Config> Pallet<T> {
<frame_system::Pallet<T>>::deposit_log(log);
}
fn initialize_authorities(authorities: &[T::AuthorityId]) {
/// Initial authorities.
///
/// The storage will be applied immediately.
///
/// The authorities length must be equal or less than T::MaxAuthorities.
pub fn initialize_authorities(authorities: &[T::AuthorityId]) {
if !authorities.is_empty() {
assert!(<Authorities<T>>::get().is_empty(), "Authorities are already initialized!");
let bounded = <BoundedSlice<'_, _, T::MaxAuthorities>>::try_from(authorities)