Skip to content
Snippets Groups Projects
Commit 074f4141 authored by Cédric Moreau's avatar Cédric Moreau Committed by Cédric Moreau
Browse files

refac: comments + renaming `ud_index` which is confusiong

parent 0deb8be5
No related branches found
No related tags found
1 merge request!301Resolve "[test] UD out of reeval window"
Pipeline #39379 passed
...@@ -24,18 +24,22 @@ pub(super) fn compute_claim_uds<Balance: AtLeast32BitUnsigned>( ...@@ -24,18 +24,22 @@ pub(super) fn compute_claim_uds<Balance: AtLeast32BitUnsigned>(
) -> (UdIndex, Balance) { ) -> (UdIndex, Balance) {
let mut total_amount = Zero::zero(); let mut total_amount = Zero::zero();
let mut total_count = 0; let mut total_count = 0;
for (ud_index, ud_amount) in past_reevals.rev() { // We start in reverse order, i.e. the most recent reeval first
if ud_index <= first_ud_index { for (reeval_index, ud_amount) in past_reevals.rev() {
// Therefore, if our first UD is above the current reeval index, we have reached our final useful reeval and must break
if reeval_index <= first_ud_index {
let count = current_ud_index - first_ud_index; let count = current_ud_index - first_ud_index;
total_amount += Balance::from(count) * ud_amount; total_amount += Balance::from(count) * ud_amount;
total_count += count; total_count += count;
// First unclaimed UD is reached; stop counting now. // First unclaimed UD is reached; stop counting now.
break; break;
} else { }
let count = current_ud_index - ud_index; // Otherwise, we consume the full reeval contained UDs
else {
let count = current_ud_index - reeval_index;
total_amount += Balance::from(count) * ud_amount; total_amount += Balance::from(count) * ud_amount;
total_count += count; total_count += count;
current_ud_index = ud_index; current_ud_index = reeval_index;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment