-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Krueger
authored and
Christian Krueger
committed
Jul 31, 2024
1 parent
e59ba78
commit 1463d29
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
programs/steward/src/instructions/admin_mark_for_removal.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
use crate::{utils::get_config_admin, Config, StewardStateAccount}; | ||
|
||
#[derive(Accounts)] | ||
pub struct AdminMarkForRemoval<'info> { | ||
#[account(mut)] | ||
pub config: AccountLoader<'info, Config>, | ||
|
||
#[account( | ||
mut, | ||
seeds = [StewardStateAccount::SEED, config.key().as_ref()], | ||
bump | ||
)] | ||
pub state_account: AccountLoader<'info, StewardStateAccount>, | ||
|
||
#[account(mut, address = get_config_admin(&config)?)] | ||
pub authority: Signer<'info>, | ||
} | ||
|
||
/* | ||
Used by the admin to unstick the machine | ||
*/ | ||
pub fn handler( | ||
ctx: Context<AdminMarkForRemoval>, | ||
validator_list_index: usize, | ||
mark_for_removal: bool, | ||
immediate: bool, | ||
) -> Result<()> { | ||
let mut state = ctx.accounts.state_account.load_mut()?; | ||
|
||
if immediate { | ||
state | ||
.state | ||
.validators_for_immediate_removal | ||
.set(validator_list_index, mark_for_removal)?; | ||
} else { | ||
state | ||
.state | ||
.validators_to_remove | ||
.set(validator_list_index, mark_for_removal)?; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters