mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 19:51:05 +00:00
Make decl_module! implement OnFinalise (#947)
This commit is contained in:
@@ -48,7 +48,7 @@ use runtime_support::storage::StorageValue;
|
||||
use runtime_support::storage::unhashed::StorageVec;
|
||||
use primitives::RuntimeString;
|
||||
use primitives::traits::{
|
||||
MaybeSerializeDebug, OnFinalise, Member, ProvideInherent, Block as BlockT
|
||||
MaybeSerializeDebug, Member, ProvideInherent, Block as BlockT
|
||||
};
|
||||
use substrate_primitives::storage::well_known_keys;
|
||||
use system::{ensure_signed, ensure_inherent};
|
||||
@@ -148,6 +148,14 @@ decl_module! {
|
||||
fn remark(origin, remark: Vec<u8>) -> Result;
|
||||
fn set_code(new: Vec<u8>) -> Result;
|
||||
fn set_storage(items: Vec<KeyValue>) -> Result;
|
||||
fn on_finalise() {
|
||||
if let Some(original_authorities) = <OriginalAuthorities<T>>::take() {
|
||||
let current_authorities = AuthorityStorageVec::<T::SessionKey>::items();
|
||||
if current_authorities != original_authorities {
|
||||
Self::deposit_log(RawLog::AuthoritiesChange(current_authorities));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,15 +275,3 @@ impl<T: Trait> ProvideInherent for Module<T> {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Finalization hook for the consensus module.
|
||||
impl<T: Trait> OnFinalise<T::BlockNumber> for Module<T> {
|
||||
fn on_finalise(_n: T::BlockNumber) {
|
||||
if let Some(original_authorities) = <OriginalAuthorities<T>>::take() {
|
||||
let current_authorities = AuthorityStorageVec::<T::SessionKey>::items();
|
||||
if current_authorities != original_authorities {
|
||||
Self::deposit_log(RawLog::AuthoritiesChange(current_authorities));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use super::*;
|
||||
use primitives::{generic, testing};
|
||||
use primitives::{generic, testing, traits::OnFinalise};
|
||||
use runtime_io::with_externalities;
|
||||
use substrate_primitives::H256;
|
||||
use mock::{Consensus, System, new_test_ext};
|
||||
|
||||
Reference in New Issue
Block a user