Skip to content

Commit

Permalink
thread: Temp fix kickoff
Browse files Browse the repository at this point in the history
  • Loading branch information
Aursen committed Oct 8, 2024
1 parent 6d1883b commit 77f0f01
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions programs/thread/src/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod thread_instruction_remove;
pub mod thread_kickoff;
pub mod thread_pause;
pub mod thread_reset;
pub mod thread_reset_next;
pub mod thread_resume;
pub mod thread_update;
pub mod thread_withdraw;
Expand All @@ -20,6 +21,7 @@ pub use thread_instruction_remove::*;
pub use thread_kickoff::*;
pub use thread_pause::*;
pub use thread_reset::*;
pub use thread_reset_next::*;
pub use thread_resume::*;
pub use thread_update::*;
pub use thread_withdraw::*;
33 changes: 33 additions & 0 deletions programs/thread/src/instructions/thread_reset_next.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use {crate::state::*, anchor_lang::prelude::*, sablier_network_program::state::Config};

/// Accounts required by the `thread_reset` instruction.
#[derive(Accounts)]
pub struct ThreadResetNext<'info> {
#[account(has_one = admin)]
pub config: AccountLoader<'info, Config>,
pub admin: Signer<'info>,
/// The thread to be paused.
#[account(mut)]
pub thread: Account<'info, Thread>,
}

pub fn handler(ctx: Context<ThreadResetNext>, timestamp: i64) -> Result<()> {
// Get accounts
let thread = &mut ctx.accounts.thread;
let clock = Clock::get()?;

// Full reset the thread state.
thread.exec_context = Some(ExecContext {
exec_index: 0,
execs_since_reimbursement: 0,
execs_since_slot: 0,
last_exec_at: clock.slot,
trigger_context: TriggerContext::Periodic {
started_at: timestamp,
},
});
thread.trigger = Trigger::Periodic { delay: 21600 };
thread.next_instruction = None;

Ok(())
}
4 changes: 4 additions & 0 deletions programs/thread/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,8 @@ pub mod thread_program {
pub fn thread_withdraw(ctx: Context<ThreadWithdraw>, amount: u64) -> Result<()> {
thread_withdraw::handler(ctx, amount)
}

pub fn thread_reset_next(ctx: Context<ThreadResetNext>, timestamp: i64) -> Result<()> {
thread_reset_next::handler(ctx, timestamp)
}
}

0 comments on commit 77f0f01

Please sign in to comment.