From ed9332d4fe6572a9e2d6825f6f13c369f225f7d9 Mon Sep 17 00:00:00 2001 From: Sabaun Taraki Date: Mon, 19 Aug 2024 14:10:42 +0300 Subject: [PATCH] Renamings, fmt --- core-processor/src/ext.rs | 8 ++++---- core/src/gas.rs | 4 ++-- core/src/reservation.rs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core-processor/src/ext.rs b/core-processor/src/ext.rs index 34572aa36d1..d69504bb81e 100644 --- a/core-processor/src/ext.rs +++ b/core-processor/src/ext.rs @@ -1201,11 +1201,11 @@ impl Externalities for Ext { fn unreserve_gas(&mut self, id: ReservationId) -> Result { 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 @@ -1213,13 +1213,13 @@ impl Externalities for Ext { .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!( diff --git a/core/src/gas.rs b/core/src/gas.rs index 58b2f24e134..aa52656e44d 100644 --- a/core/src/gas.rs +++ b/core/src/gas.rs @@ -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}, @@ -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) => { diff --git a/core/src/reservation.rs b/core/src/reservation.rs index 3f080dd2ff8..9df0e70abe3 100644 --- a/core/src/reservation.rs +++ b/core/src/reservation.rs @@ -211,7 +211,7 @@ impl GasReserver { pub fn unreserve( &mut self, id: ReservationId, - ) -> Result<(u64, Option), ReservationError> { + ) -> Result<(u64, Option), ReservationError> { // Docs error case #1. let state = self .states @@ -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"; @@ -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