From eaa90ae0abe0208273050ab3e3be433908e0d65f Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Sat, 29 Jun 2024 01:04:47 +0000 Subject: [PATCH] cleanup --- core/program/src/processor/crown.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/program/src/processor/crown.rs b/core/program/src/processor/crown.rs index e977d15..9a2975d 100644 --- a/core/program/src/processor/crown.rs +++ b/core/program/src/processor/crown.rs @@ -9,7 +9,7 @@ use solana_program::{ use crate::loaders::*; -/// Crown marks an account as the top staker if their balance is greater than the last known top staker. +/// Crown flags an account as the top staker if their balance is greater than the last known top staker. pub fn process_crown<'a, 'info>( _program_id: &Pubkey, accounts: &'a [AccountInfo<'info>], @@ -31,19 +31,17 @@ pub fn process_crown<'a, 'info>( let proof_new_data = proof_new_info.data.borrow(); let proof_new = Proof::try_from_bytes(&proof_new_data)?; - // If top staker is not the default null address, then compare balances + // If top staker is the defualt null balance, skip this. if config.top_staker.ne(&Pubkey::new_from_array([0; 32])) { // Load current top staker load_any_proof(proof_info, false)?; - let proof_data = proof_info.data.borrow(); - let proof = Proof::try_from_bytes(&proof_data)?; - - // Require the provided proof account is the current top staker - if config.top_staker.ne(&proof_info.key) { + if proof_info.key.ne(&config.top_staker) { return Ok(()); } // Compare balances + let proof_data = proof_info.data.borrow(); + let proof = Proof::try_from_bytes(&proof_data)?; if proof_new.balance.lt(&proof.balance) { return Ok(()); }