use anchor_lang::prelude::*;
#[account]
pub struct ModelResults {
pub authority: Pubkey,
pub last_update: i64,
pub latest_prediction: u8,
pub price_at_prediction: f32,
pub predictions_count: u32,
pub bump: u8,
}
impl ModelResults {
pub const LEN: usize = 8 + 32 + 8 + 1 + 4 + 8 + 1;
pub fn update_prediction(
&mut self,
prediction: u8,
price: f32
) {
self.latest_prediction = prediction;
self.price_at_prediction = price;
self.predictions_count += 1;
self.last_update = Clock::get().unwrap().unix_timestamp;
}
}