switchboard_solana/oracle_program/accounts/
crank.rs

1use crate::prelude::*;
2use bytemuck::{Pod, Zeroable};
3
4#[zero_copy(unsafe)]
5#[derive(Default)]
6#[repr(packed)]
7pub struct CrankRow {
8    /// The PublicKey of the AggregatorAccountData.
9    pub pubkey: Pubkey,
10    /// The aggregator's next available update time.
11    pub next_timestamp: i64,
12}
13unsafe impl Pod for CrankRow {}
14unsafe impl Zeroable for CrankRow {}
15
16#[account(zero_copy(unsafe))]
17#[repr(packed)]
18pub struct CrankAccountData {
19    /// Name of the crank to store on-chain.
20    pub name: [u8; 32],
21    /// Metadata of the crank to store on-chain.
22    pub metadata: [u8; 64],
23    /// Public key of the oracle queue who owns the crank.
24    pub queue_pubkey: Pubkey,
25    /// Number of aggregators added to the crank.
26    pub pq_size: u32,
27    /// Maximum number of aggregators allowed to be added to a crank.
28    pub max_rows: u32,
29    /// Pseudorandom value added to next aggregator update time.
30    pub jitter_modifier: u8,
31    /// Reserved for future info.
32    pub _ebuf: [u8; 255],
33    /// The public key of the CrankBuffer account holding a collection of Aggregator pubkeys and their next allowed update time.
34    pub data_buffer: Pubkey,
35}
36
37impl CrankAccountData {
38    pub fn size() -> usize {
39        8 + std::mem::size_of::<CrankAccountData>()
40    }
41}