forked from coal-digital/coal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.rs
27 lines (23 loc) · 826 Bytes
/
update.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use coal_api::{loaders::*, state::Proof};
use solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
};
use crate::utils::AccountDeserialize;
/// Update changes the miner authority on a proof account.
pub fn process_update<'a, 'info>(
accounts: &'a [AccountInfo<'info>],
_data: &[u8],
) -> ProgramResult {
// Load accounts.
let [signer, miner_info, proof_info] = accounts else {
return Err(ProgramError::NotEnoughAccountKeys);
};
load_signer(signer)?;
load_any(miner_info, false)?;
load_proof(proof_info, signer.key, true)?;
// Update the proof's miner authority.
let mut proof_data = proof_info.data.borrow_mut();
let proof = Proof::try_from_bytes_mut(&mut proof_data)?;
proof.miner = *miner_info.key;
Ok(())
}