miclockwork_thread_program/instructions/
thread_pause.rs

1use {crate::state::*, anchor_lang::prelude::*};
2
3/// Accounts required by the `thread_delete` instruction.
4#[derive(Accounts)]
5pub struct ThreadPause<'info> {
6    /// The authority (owner) of the thread.
7    #[account()]
8    pub authority: Signer<'info>,
9
10    /// The thread to be paused.
11    #[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<ThreadPause>) -> Result<()> {
25    // Get accounts
26    let thread = &mut ctx.accounts.thread;
27
28    // Pause the thread
29    thread.paused = true;
30
31    Ok(())
32}