sigil-validator-agent · cycle_budget
Source declarations, signatures and documentation for cycle_budget.
Source: sigil/node/sigil-validator-agent/src/cycle_budget.rs. SHA-256: 0bb39f436c288d0c2479dfe42222e839e6349be8fb102f6b2d288dcc3652704c.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
cycle_budget::CycleBudgetError
#[derive(Debug, thiserror::Error)]
pub enum CycleBudgetError {
#[error("epoch {epoch} budget exhausted: requested {requested}, remaining {remaining}")]
Exhausted {
epoch: u64,
requested: u64,
remaining: u64,
},
}Source line: 13.
cycle_budget::CycleBudget
Per-epoch cycle budget tracker.
The runtime calls [Self::reserve] before dispatching an L3 call.
On epoch rollover, [Self::roll_over_to_epoch] resets the remaining
balance to the configured budget. The tracker is Send + Sync and
safe to share across the runtime's tasks via Arc.
#[derive(Debug)]
pub struct CycleBudget {
}Source line: 29.
cycle_budget::CycleBudget::new
pub fn new(budget_per_epoch: u64, starting_epoch: u64) -> Self;Source line: 42.
cycle_budget::CycleBudget::budget_per_epoch
Configured per-epoch budget.
pub fn budget_per_epoch(&self) -> u64;Source line: 54.
cycle_budget::CycleBudget::current_epoch
Current epoch.
pub fn current_epoch(&self) -> u64;Source line: 59.
cycle_budget::CycleBudget::remaining
Remaining cycles available in the current epoch.
pub fn remaining(&self) -> u64;Source line: 64.
cycle_budget::CycleBudget::consumed_this_epoch
Cycles consumed so far in the current epoch.
pub fn consumed_this_epoch(&self) -> u64;Source line: 69.
cycle_budget::CycleBudget::reserve
Try to reserve cycles from the current epoch's budget.
Returns Ok if reserved, Err if the reservation would exceed the remaining balance. The reservation is debited atomically.
pub fn reserve(&self, cycles: u64) -> Result<(), CycleBudgetError>;Source line: 77.
cycle_budget::CycleBudget::roll_over_to_epoch
Roll over to a new epoch. Resets the remaining balance to the
configured budget. No-op if new_epoch == current_epoch.
Rejects backward rollover (returns Err) — epochs only advance.
pub fn roll_over_to_epoch(&self, new_epoch: u64) -> Result<(), &'static str>;Source line: 94.