1use steel::*;
2
3use super::EntropyAccount;
4
5#[repr(C)]
6#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
7pub struct Var {
8 pub authority: Pubkey,
10
11 pub provider: Pubkey,
13
14 pub commit: [u8; 32],
16
17 pub seed: [u8; 32],
19
20 pub slot_hash: [u8; 32],
22
23 pub value: [u8; 32],
25
26 pub samples: u64,
28
29 pub is_auto: u64,
31
32 pub start_at: u64,
34
35 pub end_at: u64,
37}
38
39impl Var {
40 pub fn is_valid(&self, seed: [u8; 32]) -> bool {
41 if self.slot_hash == [0; 32] {
42 return false;
43 }
44 if self.value != [0; 32] {
45 return false;
46 }
47 if self.samples == 0 {
48 return false;
49 }
50 let expected_commit = solana_program::keccak::hash(&seed).to_bytes();
51 expected_commit == self.commit
52 }
53}
54
55account!(EntropyAccount, Var);