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
use {
crate::{errors::*, objects::*},
anchor_lang::prelude::*,
clockwork_network_program::objects::{Worker, WorkerAccount},
};
#[derive(Accounts)]
#[instruction(data_hash: Option<u64>)]
pub struct QueueKickoff<'info> {
#[account(
mut,
seeds = [
SEED_QUEUE,
queue.authority.as_ref(),
queue.id.as_bytes(),
],
bump,
constraint = !queue.paused @ ClockworkError::QueuePaused,
constraint = queue.next_instruction.is_none() @ ClockworkError::QueueBusy,
)]
pub queue: Box<Account<'info, Queue>>,
#[account(mut)]
pub signatory: Signer<'info>,
#[account(
address = worker.pubkey(),
has_one = signatory
)]
pub worker: Account<'info, Worker>,
}
pub fn handler(ctx: Context<QueueKickoff>, data_hash: Option<u64>) -> Result<()> {
let queue = &mut ctx.accounts.queue;
queue.kickoff(data_hash, ctx.remaining_accounts)?;
Ok(())
}