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
use {
crate::state::*,
anchor_lang::prelude::*,
};
#[derive(Accounts)]
#[instruction()]
pub struct HealthCheck<'info> {
pub clock: Sysvar<'info, Clock>,
#[account(
seeds = [SEED_AUTHORITY],
bump = authority.bump,
owner = crate::ID,
)]
pub authority: Account<'info, Authority>,
#[account(
mut,
seeds = [
SEED_DAEMON,
daemon.owner.as_ref()
],
bump = daemon.bump,
constraint = daemon.owner == authority.key(),
owner = crate::ID,
signer
)]
pub daemon: Account<'info, Daemon>,
#[account(
mut,
seeds = [SEED_HEALTH],
bump = health.bump,
owner = crate::ID,
)]
pub health: Account<'info, Health>,
}
pub fn handler(ctx: Context<HealthCheck>) -> ProgramResult {
let clock = &ctx.accounts.clock;
let health = &mut ctx.accounts.health;
health.target_time = health.target_time.checked_add(1).unwrap();
health.real_time = clock.unix_timestamp;
Ok(())
}