mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 23:16:48 +00:00
pause
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
mod claim;
|
||||
mod initialize;
|
||||
mod mine;
|
||||
mod pause;
|
||||
mod register;
|
||||
mod reset;
|
||||
mod stake;
|
||||
@@ -10,6 +11,7 @@ mod upgrade;
|
||||
pub use claim::*;
|
||||
pub use initialize::*;
|
||||
pub use mine::*;
|
||||
pub use pause::*;
|
||||
pub use register::*;
|
||||
pub use reset::*;
|
||||
pub use stake::*;
|
||||
|
||||
34
src/processor/pause.rs
Normal file
34
src/processor/pause.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
||||
use crate::{instruction::PauseArgs, loaders::*, state::Config, utils::AccountDeserialize};
|
||||
|
||||
pub fn process_pause<'a, 'info>(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &'a [AccountInfo<'info>],
|
||||
data: &[u8],
|
||||
) -> ProgramResult {
|
||||
// Parse args
|
||||
let args = PauseArgs::try_from_bytes(data)?;
|
||||
|
||||
// Load accounts
|
||||
let [signer, config_info] = accounts else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
load_signer(signer)?;
|
||||
load_config(config_info, true)?;
|
||||
|
||||
// Validate signer is admin
|
||||
let mut config_data = config_info.data.borrow_mut();
|
||||
let config = Config::try_from_bytes_mut(&mut config_data)?;
|
||||
if config.admin.ne(&signer.key) {
|
||||
return Err(ProgramError::MissingRequiredSignature);
|
||||
}
|
||||
|
||||
// Update paused
|
||||
config.paused = args.paused as u32;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user