mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 23:16:52 +00:00
log
This commit is contained in:
@@ -124,6 +124,8 @@ pub fn deploy(
|
||||
let miner_address = miner_pda(signer).0;
|
||||
let square_address = square_pda().0;
|
||||
|
||||
// Convert array of 25 booleans into a 32-bit mask where each bit represents whether
|
||||
// that square index is selected (1) or not (0)
|
||||
let mut mask: u32 = 0;
|
||||
for (i, &square) in squares.iter().enumerate() {
|
||||
if square {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use ore_api::prelude::*;
|
||||
use solana_program::log::sol_log;
|
||||
use spl_token::amount_to_ui_amount;
|
||||
use steel::*;
|
||||
|
||||
/// Claims a block reward.
|
||||
@@ -43,6 +45,14 @@ pub fn process_claim_ore(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRe
|
||||
// Normalize amount.
|
||||
let amount = miner.rewards_ore.min(amount);
|
||||
|
||||
sol_log(
|
||||
&format!(
|
||||
"Claiming {} ORE",
|
||||
amount_to_ui_amount(amount, TOKEN_DECIMALS)
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
|
||||
// Update miner.
|
||||
miner.rewards_ore -= amount;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use ore_api::prelude::*;
|
||||
use solana_program::{log::sol_log, native_token::lamports_to_sol};
|
||||
use steel::*;
|
||||
|
||||
/// Claims a block reward.
|
||||
@@ -20,6 +21,8 @@ pub fn process_claim_sol(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRe
|
||||
// Normalize amount.
|
||||
let amount = miner.rewards_sol.min(amount);
|
||||
|
||||
sol_log(&format!("Claiming {} SOL", lamports_to_sol(amount)).as_str());
|
||||
|
||||
// Update miner.
|
||||
miner.rewards_sol -= amount;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use ore_api::prelude::*;
|
||||
use solana_program::{log::sol_log, native_token::lamports_to_sol};
|
||||
use steel::*;
|
||||
|
||||
use crate::whitelist::AUTHORIZED_ACCOUNTS;
|
||||
@@ -10,12 +11,23 @@ pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
|
||||
let amount = u64::from_le_bytes(args.amount);
|
||||
let mask = u32::from_le_bytes(args.squares);
|
||||
|
||||
// Parse squares.
|
||||
// Convert 32-bit mask into array of 25 booleans, where each bit in the mask
|
||||
// determines if that square index is selected (true) or not (false)
|
||||
let mut squares = [false; 25];
|
||||
for i in 0..25 {
|
||||
squares[i] = (mask & (1 << i)) != 0;
|
||||
}
|
||||
|
||||
sol_log(
|
||||
&format!(
|
||||
"Deploying {} SOL to {} squares: {:?}",
|
||||
lamports_to_sol(amount),
|
||||
squares.iter().filter(|&&s| s).count(),
|
||||
squares
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
|
||||
// Load accounts.
|
||||
let clock = Clock::get()?;
|
||||
let [signer_info, board_info, config_info, fee_collector_info, miner_info, square_info, system_program] =
|
||||
|
||||
Reference in New Issue
Block a user