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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use crate::anchor_traits::*;
use switchboard_common::cfg_client;
use crate::impl_account_deserialize;
use crate::get_sb_program_id;
use solana_program::pubkey::Pubkey;

#[derive(Default)]
#[repr(C)]
#[derive(bytemuck::Zeroable, bytemuck::Pod, Debug, Copy, Clone)]
pub struct OracleEpochInfo {
    pub id: u64,
    pub reserved1: u64,
    pub slot_end: u64,
    pub slash_score: u64,
    pub reward_score: u64,
    pub stake_score: u64,
}

#[derive(Default)]
#[repr(C)]
#[derive(bytemuck::Zeroable, bytemuck::Pod, Debug, Copy, Clone)]
pub struct MegaSlotInfo {
    pub reserved1: u64,
    pub slot_end: u64,
    pub perf_goal: i64,
    pub current_signature_count: i64,
}

#[repr(C)]
#[derive(bytemuck::Zeroable, bytemuck::Pod, Debug, Copy, Clone)]
pub struct OracleStatsAccountData {
    pub owner: Pubkey,
    pub oracle: Pubkey,
    /// The last epoch that has completed. cleared after registered with the
    /// staking program.
    pub finalized_epoch: OracleEpochInfo,
    /// The current epoch info being used by the oracle. for stake. Will moved
    /// to finalized_epoch as soon as the epoch is over.
    pub current_epoch: OracleEpochInfo,
    pub mega_slot_info: MegaSlotInfo,
    pub last_transfer_slot: u64,
    pub bump: u8,
    pub padding1: [u8; 7],
    /// Reserved.
    pub _ebuf: [u8; 1024],
}
impl Owner for OracleStatsAccountData {
    fn owner() -> Pubkey {
        let cluster = std::env::var("CLUSTER").unwrap_or("mainnet".to_string());
        get_sb_program_id(&cluster)
    }
}
impl Discriminator for OracleStatsAccountData {
    const DISCRIMINATOR: [u8; 8] = [180, 157, 178, 234, 240, 27, 152, 179];
}
cfg_client! {
    impl_account_deserialize!(OracleStatsAccountData);
}
impl OracleStatsAccountData {
    cfg_client! {

        pub async fn fetch_async(
            client: &solana_client::nonblocking::rpc_client::RpcClient,
            pubkey: Pubkey,
        ) -> std::result::Result<Self, crate::OnDemandError> {
            crate::client::fetch_zerocopy_account_async(client, pubkey).await
        }

    }
}