1pub use crate::*;
4
5#[account]
7#[derive(Copy, Default, Debug, PartialEq, Eq)]
8pub struct Operator {
9 pub base: Pubkey,
11 pub bump: u8,
13
14 pub rewarder: Pubkey,
16 pub admin: Pubkey,
18
19 pub rate_setter: Pubkey,
21 pub quarry_creator: Pubkey,
23 pub share_allocator: Pubkey,
25
26 pub last_modified_ts: i64,
28 pub generation: u64,
31}
32
33impl Operator {
34 pub const LEN: usize = 32 + 1 + 32 + 32 + 32 + 32 + 32 + 8 + 8;
36
37 pub(crate) fn record_update(&mut self) -> Result<()> {
38 self.last_modified_ts = Clock::get()?.unix_timestamp;
39 self.generation = unwrap_int!(self.generation.checked_add(1));
40 Ok(())
41 }
42}
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_operator_len() {
50 assert_eq!(
51 Operator::default().try_to_vec().unwrap().len(),
52 Operator::LEN
53 );
54 }
55}