mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-20 07:26:50 +00:00
boost event
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use ore_utils::*;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
@@ -9,4 +10,11 @@ pub struct MineEvent {
|
||||
pub timing: i64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct BoostEvent {
|
||||
pub mint: Pubkey,
|
||||
pub reward: u64,
|
||||
}
|
||||
event!(MineEvent);
|
||||
event!(BoostEvent);
|
||||
|
||||
@@ -59,18 +59,30 @@ pub fn close(signer: Pubkey) -> Instruction {
|
||||
}
|
||||
|
||||
/// Builds a mine instruction.
|
||||
pub fn mine(signer: Pubkey, authority: Pubkey, bus: Pubkey, solution: Solution) -> Instruction {
|
||||
pub fn mine(
|
||||
signer: Pubkey,
|
||||
authority: Pubkey,
|
||||
bus: Pubkey,
|
||||
solution: Solution,
|
||||
boost_accounts: Vec<Pubkey>,
|
||||
) -> Instruction {
|
||||
let proof = proof_pda(authority).0;
|
||||
let accounts = vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(bus, false),
|
||||
AccountMeta::new_readonly(CONFIG_ADDRESS, false),
|
||||
AccountMeta::new(proof, false),
|
||||
AccountMeta::new_readonly(sysvar::instructions::id(), false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
|
||||
];
|
||||
let boost_accounts = boost_accounts
|
||||
.into_iter()
|
||||
.map(|pk| AccountMeta::new_readonly(pk, false))
|
||||
.collect();
|
||||
let accounts = [accounts, boost_accounts].concat();
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(bus, false),
|
||||
AccountMeta::new_readonly(CONFIG_ADDRESS, false),
|
||||
AccountMeta::new(proof, false),
|
||||
AccountMeta::new_readonly(sysvar::instructions::id(), false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
|
||||
],
|
||||
accounts,
|
||||
data: Mine {
|
||||
digest: solution.d,
|
||||
nonce: solution.n,
|
||||
|
||||
Reference in New Issue
Block a user