clockwork_crank/instructions/
queue_resume.rs

1use {
2    crate::state::*,
3    anchor_lang::prelude::*,
4};
5
6#[derive(Accounts)]
7pub struct QueueResume<'info> {
8    #[account()]
9    pub authority: Signer<'info>,
10
11    #[account(
12        mut,
13        seeds = [
14            SEED_QUEUE, 
15            queue.authority.key().as_ref(),
16            queue.id.as_bytes(),
17        ],
18        bump,
19        has_one = authority
20    )]
21    pub queue: Account<'info, Queue>,
22}
23
24pub fn handler(ctx: Context<QueueResume>) -> Result<()> {
25    // Get accounts
26    let queue = &mut ctx.accounts.queue;
27    
28    // Resume the queue
29    queue.is_paused = false;
30
31    // Update the exec context
32    match queue.exec_context {
33        None => {}
34        Some(exec_context) => {
35            match exec_context {
36                ExecContext::Cron { started_at: _ } => {
37                    // Jump ahead to the current timestamp
38                    queue.exec_context = Some(ExecContext::Cron { started_at: Clock::get().unwrap().unix_timestamp });
39                }
40                ExecContext::Immediate => {
41                    // Nothing to do
42                }
43            }
44        }
45    }
46
47    Ok(())
48}