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
use {crate::objects::*, anchor_lang::prelude::*};

#[derive(Accounts)]
pub struct PoolRotate<'info> {
    #[account(
        address = Config::pubkey(), 
        has_one = pool_authority
    )]
    pub config: Account<'info, Config>,

    #[account(mut, address = pool.pubkey())]
    pub pool: Account<'info, Pool>,

    #[account()]
    pub pool_authority: Signer<'info>,

    #[account()]
    pub worker: SystemAccount<'info>,
}

pub fn handler(ctx: Context<PoolRotate>) -> Result<()> {
    // Get accounts
    let pool = &mut ctx.accounts.pool;
    let worker = &ctx.accounts.worker;

    // Rotate the worker into the pool
    pool.rotate(worker.key())?;

    Ok(())
}