light_registry/selection/
forester.rs1use aligned_sized::aligned_sized;
2use anchor_lang::{prelude::*, solana_program::pubkey::Pubkey};
3
4use crate::{constants::FORESTER_SEED, protocol_config::state::ProtocolConfigPda};
5
6#[aligned_sized(anchor)]
7#[account]
8#[derive(Debug, Default, Copy, PartialEq, Eq)]
9pub struct ForesterPda {
10 pub authority: Pubkey,
11 pub config: ForesterConfig,
12 pub active_weight: u64,
13 pub pending_weight: u64,
15 pub current_epoch: u64,
16 pub last_compressed_forester_epoch_pda_hash: [u8; 32],
18 pub last_registered_epoch: u64,
19}
20
21#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, AnchorDeserialize, AnchorSerialize)]
22pub struct ForesterConfig {
23 pub fee: u64,
25}
26
27#[derive(Accounts)]
28#[instruction(bump: u8, forester_authority: Pubkey)]
29pub struct RegisterForester<'info> {
30 #[account(mut)]
31 pub fee_payer: Signer<'info>,
32 pub authority: Signer<'info>,
33 #[account(has_one = authority)]
34 pub protocol_config_pda: Account<'info, ProtocolConfigPda>,
35 #[account(init, seeds = [FORESTER_SEED, forester_authority.as_ref()], bump, space =ForesterPda::LEN , payer = fee_payer)]
36 pub forester_pda: Account<'info, ForesterPda>,
37 system_program: Program<'info, System>,
38}
39
40#[derive(Accounts)]
41pub struct UpdateForesterPda<'info> {
42 pub authority: Signer<'info>,
43 #[account(mut, has_one = authority)]
45 pub forester_pda: Account<'info, ForesterPda>,
46 pub new_authority: Option<Signer<'info>>,
47}
48
49#[derive(Accounts)]
50pub struct UpdateForesterPdaWeight<'info> {
51 pub authority: Signer<'info>,
52 #[account(has_one = authority)]
53 pub protocol_config_pda: Account<'info, ProtocolConfigPda>,
54 #[account(mut)]
55 pub forester_pda: Account<'info, ForesterPda>,
56}