miclockwork_thread_program/instructions/
thread_resume.rs1use {crate::state::*, anchor_lang::prelude::*};
2
3#[derive(Accounts)]
5pub struct ThreadResume<'info> {
6 #[account()]
8 pub authority: Signer<'info>,
9
10 #[account(
12 mut,
13 seeds = [
14 SEED_THREAD,
15 thread.authority.as_ref(),
16 thread.id.as_slice(),
17 ],
18 bump = thread.bump,
19 has_one = authority
20 )]
21 pub thread: Account<'info, Thread>,
22}
23
24pub fn handler(ctx: Context<ThreadResume>) -> Result<()> {
25 let thread = &mut ctx.accounts.thread;
27
28 thread.paused = false;
30
31 match thread.exec_context {
33 None => {}
34 Some(exec_context) => {
35 match exec_context.trigger_context {
36 TriggerContext::Cron { started_at: _ } => {
37 thread.exec_context = Some(ExecContext {
39 trigger_context: TriggerContext::Cron {
40 started_at: Clock::get().unwrap().unix_timestamp,
41 },
42 ..exec_context
43 });
44 }
45 _ => {
46 }
48 }
49 }
50 }
51
52 Ok(())
53}