Skip to content

Commit

Permalink
Renamings, fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
techraed committed Aug 19, 2024
1 parent 636ca1c commit ed9332d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions core-processor/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,25 +1201,25 @@ impl<LP: LazyPagesInterface> Externalities for Ext<LP> {
fn unreserve_gas(&mut self, id: ReservationId) -> Result<u64, Self::FallibleError> {
let (amount, reimburse) = self.context.gas_reserver.unreserve(id)?;

if let Some(reimburse) = reimburse {
if let Some(reimbursement) = reimburse {
let current_gas_amount = self.gas_amount();

// Basically amount of the reseravtion and the cost for the hold duration.
let reimburse_amount = self
let reimbursement_amount = self
.context
.costs
.rent
.reservation
.cost_for(
self.context
.reserve_for
.saturating_add(reimburse.duration())
.saturating_add(reimbursement.duration())
.into(),
)
.saturating_add(amount);
self.context
.gas_counter
.increase(reimburse_amount, reimburse)
.increase(reimbursement_amount, reimbursement)
.then_some(())
.unwrap_or_else(|| {
unreachable!(
Expand Down
4 changes: 2 additions & 2 deletions core/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

//! Gas module.
use crate::{costs::CostToken, reservation::ReimburseUnreserved};
use crate::{costs::CostToken, reservation::UnreservedReimbursement};
use enum_iterator::Sequence;
use scale_info::{
scale::{Decode, Encode},
Expand Down Expand Up @@ -103,7 +103,7 @@ impl GasCounter {
///
/// Called when gas unreservation is occurred.
/// We don't decrease `burn` counter because `GasTree` manipulation is handled by separated function
pub fn increase(&mut self, amount: u64, _token: ReimburseUnreserved) -> bool {
pub fn increase(&mut self, amount: u64, _token: UnreservedReimbursement) -> bool {
match self.left.checked_add(amount) {
None => false,
Some(new_left) => {
Expand Down
8 changes: 4 additions & 4 deletions core/src/reservation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl GasReserver {
pub fn unreserve(
&mut self,
id: ReservationId,
) -> Result<(u64, Option<ReimburseUnreserved>), ReservationError> {
) -> Result<(u64, Option<UnreservedReimbursement>), ReservationError> {
// Docs error case #1.
let state = self
.states
Expand Down Expand Up @@ -239,7 +239,7 @@ impl GasReserver {
}
GasReservationState::Created {
amount, duration, ..
} => (amount, Some(ReimburseUnreserved(duration))),
} => (amount, Some(UnreservedReimbursement(duration))),
GasReservationState::Removed { .. } => {
let err_msg =
"GasReserver::unreserve: `Removed` variant is unreachable, checked above";
Expand Down Expand Up @@ -337,9 +337,9 @@ impl GasReserver {
///
/// Wraps duration for the newly created reservation.
#[derive(Debug, PartialEq, Eq)]
pub struct ReimburseUnreserved(u32);
pub struct UnreservedReimbursement(u32);

impl ReimburseUnreserved {
impl UnreservedReimbursement {
/// Returns duration for the newly created unreserved reservation.
pub fn duration(&self) -> u32 {
self.0
Expand Down

0 comments on commit ed9332d

Please sign in to comment.