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
pub use crate::*;
#[account]
#[derive(Copy, Default, Debug, PartialEq, Eq)]
pub struct Operator {
pub base: Pubkey,
pub bump: u8,
pub rewarder: Pubkey,
pub admin: Pubkey,
pub rate_setter: Pubkey,
pub quarry_creator: Pubkey,
pub share_allocator: Pubkey,
pub last_modified_ts: i64,
pub generation: u64,
}
impl Operator {
pub const LEN: usize = 32 + 1 + 32 + 32 + 32 + 32 + 32 + 8 + 8;
pub(crate) fn record_update(&mut self) -> Result<()> {
self.last_modified_ts = Clock::get()?.unix_timestamp;
self.generation = unwrap_int!(self.generation.checked_add(1));
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_operator_len() {
assert_eq!(
Operator::default().try_to_vec().unwrap().len(),
Operator::LEN
);
}
}