Struct linera_execution::ResourceController
source · pub struct ResourceController<Account = Amount, Tracker = ResourceTracker> {
pub policy: Arc<ResourceControlPolicy>,
pub tracker: Tracker,
pub account: Account,
}Fields§
§policy: Arc<ResourceControlPolicy>The (fixed) policy used to charge fees and control resource usage.
tracker: TrackerHow the resources were used so far.
account: AccountThe account paying for the resource usage.
Implementations§
source§impl<Account, Tracker> ResourceController<Account, Tracker>where
Account: BalanceHolder,
Tracker: AsMut<ResourceTracker>,
impl<Account, Tracker> ResourceController<Account, Tracker>where
Account: BalanceHolder,
Tracker: AsMut<ResourceTracker>,
sourcepub fn balance(&self) -> Result<Amount, ArithmeticError>
pub fn balance(&self) -> Result<Amount, ArithmeticError>
Obtains the balance of the account. The only possible error is an arithmetic overflow, which should not happen in practice due to final token supply.
sourcepub fn merge_balance(
&mut self,
initial: Amount,
other: Amount
) -> Result<(), ExecutionError>
pub fn merge_balance( &mut self, initial: Amount, other: Amount ) -> Result<(), ExecutionError>
Operates a 3-way merge by transferring the difference between initial
and other to self.
sourcepub fn track_grant(&mut self, grant: Amount) -> Result<(), ExecutionError>
pub fn track_grant(&mut self, grant: Amount) -> Result<(), ExecutionError>
Tracks the allocation of a grant.
sourcepub fn track_block(&mut self) -> Result<(), ExecutionError>
pub fn track_block(&mut self) -> Result<(), ExecutionError>
Tracks the creation of a block.
sourcepub fn track_operation(
&mut self,
operation: &Operation
) -> Result<(), ExecutionError>
pub fn track_operation( &mut self, operation: &Operation ) -> Result<(), ExecutionError>
Tracks the execution of an operation in block.
sourcepub fn track_message(&mut self, message: &Message) -> Result<(), ExecutionError>
pub fn track_message(&mut self, message: &Message) -> Result<(), ExecutionError>
Tracks the creation of an outgoing message.
source§impl ResourceController<Option<Owner>, ResourceTracker>
impl ResourceController<Option<Owner>, ResourceTracker>
sourcepub async fn with_state<'a, C>(
&mut self,
view: &'a mut ExecutionStateView<C>
) -> Result<ResourceController<Sources<'a>, &mut ResourceTracker>, ViewError>
pub async fn with_state<'a, C>( &mut self, view: &'a mut ExecutionStateView<C> ) -> Result<ResourceController<Sources<'a>, &mut ResourceTracker>, ViewError>
Provides a reference to the current execution state and obtains a temporary object
where the accounting functions of ResourceController are available.
sourcepub async fn with_state_and_grant<'a, C>(
&mut self,
view: &'a mut ExecutionStateView<C>,
grant: Option<&'a mut Amount>
) -> Result<ResourceController<Sources<'a>, &mut ResourceTracker>, ViewError>
pub async fn with_state_and_grant<'a, C>( &mut self, view: &'a mut ExecutionStateView<C>, grant: Option<&'a mut Amount> ) -> Result<ResourceController<Sources<'a>, &mut ResourceTracker>, ViewError>
Provides a reference to the current execution state as well as an optional grant,
and obtains a temporary object where the accounting functions of
ResourceController are available.
Trait Implementations§
source§impl<Account: Clone, Tracker: Clone> Clone for ResourceController<Account, Tracker>
impl<Account: Clone, Tracker: Clone> Clone for ResourceController<Account, Tracker>
source§fn clone(&self) -> ResourceController<Account, Tracker>
fn clone(&self) -> ResourceController<Account, Tracker>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more