Skip to content

Commit

Permalink
Add set_immortals()
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Nov 22, 2020
1 parent 6f2c874 commit 6b1d5ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("chainx"),
impl_name: create_runtime_str!("chainx-net"),
authoring_version: 1,
spec_version: 3,
spec_version: 4,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
18 changes: 10 additions & 8 deletions xpallets/mining/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,6 @@ decl_module! {

fn deposit_event() = default;

/// Remove this once `Immortals` is initialized.
fn on_runtime_upgrade() -> frame_support::weights::Weight {
// The `validator` call is still disallowed when initializing so
// immortals are just the genesis validators.
Immortals::<T>::put(Self::active_validator_set().collect::<Vec<_>>());
1
}

/// Nominate the `target` with `value` of the origin account's balance locked.
#[weight = T::WeightInfo::bond()]
pub fn bond(origin, target: <T::Lookup as StaticLookup>::Source, #[compact] value: BalanceOf<T>) {
Expand Down Expand Up @@ -516,6 +508,16 @@ decl_module! {
ensure_root(origin)?;
SessionsPerEra::put(new);
}

#[weight = 10_000_000]
fn set_immortals(origin, new: Vec<T::AccountId>) {
ensure_root(origin)?;
if new.is_empty() {
Immortals::<T>::kill()
} else {
Immortals::<T>::put(new);
}
}
}
}

Expand Down

0 comments on commit 6b1d5ce

Please sign in to comment.