canic_core/api/runtime/
root_funding.rs1pub use crate::ops::runtime::root_funding::{
2 RootFundingRuntime, RootFundingRuntimeApi, RootFundingRuntimeConfig,
3};
4
5pub struct RootFundingTimerApi;
7
8impl RootFundingTimerApi {
9 pub fn reconcile() -> Result<(), crate::dto::error::Error> {
11 crate::workflow::runtime::cycles::CycleWorkflow::start().map_err(Into::into)
12 }
13
14 pub fn prepare_policy_rotation_fence() -> Result<(), crate::error::InternalError> {
16 use crate::{
17 ops::storage::{async_job_recovery::AsyncJobOwner, icp_refill::IcpRefillStoreOps},
18 workflow::runtime::async_job::AsyncJobWorkflow,
19 };
20
21 if AsyncJobWorkflow::has_active_attempt(AsyncJobOwner::CycleTopup)
22 || IcpRefillStoreOps::resumable_operation_count() != 0
23 {
24 return Err(crate::error::InternalError::conflict());
25 }
26 crate::workflow::runtime::cycles::CycleWorkflow::cancel_timer()?;
27 Ok(())
28 }
29
30 pub fn fence_for_deletion() -> Result<(), crate::error::InternalError> {
32 use crate::{
33 ops::storage::{
34 async_job_recovery::AsyncJobOwner,
35 icp_refill::IcpRefillStoreOps,
36 state::fleet::{FleetStateCommand, FleetStateOps},
37 },
38 workflow::runtime::async_job::AsyncJobWorkflow,
39 };
40
41 if AsyncJobWorkflow::has_active_attempt(AsyncJobOwner::CycleTopup)
42 || IcpRefillStoreOps::resumable_operation_count() != 0
43 {
44 return Err(crate::error::InternalError::conflict());
45 }
46 let _ = FleetStateOps::execute_command(FleetStateCommand::SetCyclesFundingEnabled(false));
47 crate::workflow::runtime::cycles::CycleWorkflow::cancel_timer()?;
48 Ok(())
49 }
50}