From 6019d996c7021611d4b067f6f6d6e89c7637f4f2 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Tue, 3 Oct 2023 17:28:47 +0300 Subject: [PATCH] Fix for solution sorting by quality --- crates/subspace-farmer-components/src/auditing.rs | 8 ++------ crates/subspace-farmer/src/single_disk_farm/farming.rs | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/subspace-farmer-components/src/auditing.rs b/crates/subspace-farmer-components/src/auditing.rs index c92363343b..5a0416f569 100644 --- a/crates/subspace-farmer-components/src/auditing.rs +++ b/crates/subspace-farmer-components/src/auditing.rs @@ -106,10 +106,7 @@ where return None; } - winning_audit_chunks.sort_by(|a, b| { - // Comparing `b` to `a` because we want smaller values first - b.solution_distance.cmp(&a.solution_distance) - }); + winning_audit_chunks.sort_by(|a, b| a.solution_distance.cmp(&b.solution_distance)); Some(ChunkCandidate { chunk_offset: chunk_offset as u32, @@ -135,8 +132,7 @@ where .expect("Lists of audit chunks are non-empty; qed") .solution_distance; - // Comparing `b` to `a` because we want smaller values first - b_solution_distance.cmp(&a_solution_distance) + a_solution_distance.cmp(&b_solution_distance) }); let best_solution_distance = winning_chunks diff --git a/crates/subspace-farmer/src/single_disk_farm/farming.rs b/crates/subspace-farmer/src/single_disk_farm/farming.rs index 44369c9c78..d8bce4c761 100644 --- a/crates/subspace-farmer/src/single_disk_farm/farming.rs +++ b/crates/subspace-farmer/src/single_disk_farm/farming.rs @@ -189,8 +189,7 @@ where let b_solution_distance = b.1.best_solution_distance().unwrap_or(SolutionRange::MAX); - // Comparing `b` to `a` because we want smaller values first - b_solution_distance.cmp(&a_solution_distance) + a_solution_distance.cmp(&b_solution_distance) }); let mut solutions = Vec::>::new();