Skip to content

Commit

Permalink
solve review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Apr 18, 2023
1 parent 841f12a commit cd848b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pallets/loans-ref/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ pub mod pallet {
/// - Time passes and the policy can be applied.
/// - Write of with a policy that says: percentage 0.3, penaly 0.4
/// - The loan is written off with the maximum between the policy and the current rule:
/// percentage 0.5, penaly 0.4
/// percentage 0.5, penalty 0.4
///
/// No special permisions are required to this call.
/// The portfolio valuation of the pool is updated to reflect the new present value of the loan.
Expand Down Expand Up @@ -688,7 +688,7 @@ pub mod pallet {
})
}

/// From all overdue write off rules, it returns the one has highest percentage
/// From all overdue write off rules, it returns the one with the highest percentage
/// (or highest penalty, if same percentage) that can be applied.
///
/// Suppose a policy with the following rules:
Expand All @@ -697,7 +697,7 @@ pub mod pallet {
/// - overdue_days: 15, percentage 20%
///
/// If the loan is not overdue, it will not return any rule.
/// If the loan overdue by 4 days, it will not return any rule.
/// If the loan is overdue by 4 days, it will not return any rule.
/// If the loan is overdue by 9 days, it will return the first rule.
/// If the loan is overdue by 60 days, it will return the second rule
/// (because it has a higher percetage).
Expand Down
6 changes: 3 additions & 3 deletions pallets/loans-ref/src/migrations/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ impl<T: Config> OnRuntimeUpgrade for Migration<T> {
fn on_runtime_upgrade() -> Weight {
if Pallet::<T>::on_chain_storage_version() > StorageVersion::new(0) {
log::warn!("Migration was already done. This migration can be removed");
return Weight::zero();
return T::DbWeight::get().reads(1);
}

let mut count = 0;
let mut count: u64 = 0;
WriteOffPolicy::<T>::translate_values(|policy: v0::WriteOffStates<T>| {
count += 1;
Some(
Expand All @@ -62,7 +62,7 @@ impl<T: Config> OnRuntimeUpgrade for Migration<T> {

log::info!("Successful migration: v0 -> v1. Items: {count}");

T::DbWeight::get().reads_writes(count, count)
T::DbWeight::get().reads_writes(count.saturating_add(1), count.saturating_add(1))
}

#[cfg(feature = "try-runtime")]
Expand Down

0 comments on commit cd848b7

Please sign in to comment.