From 28d845e201dea4e0598ec807eae86534ea66a753 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Mon, 23 Oct 2023 18:37:54 -0700 Subject: [PATCH] Handle empty solutions case after filter --- ledger/src/advance.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ledger/src/advance.rs b/ledger/src/advance.rs index de002dd214..b8896e7611 100644 --- a/ledger/src/advance.rs +++ b/ledger/src/advance.rs @@ -135,14 +135,20 @@ impl> Ledger { .verify(coinbase_verifying_key, &latest_epoch_challenge, self.latest_proof_target()) .unwrap_or(false) }); - // Construct the solutions. - let solutions = CoinbaseSolution::new(valid_candidate_solutions)?; - // Compute the solutions root. - let solutions_root = solutions.to_accumulator_point()?; - // Compute the combined proof target. - let combined_proof_target = solutions.to_combined_proof_target()?; - // Output the solutions, solutions root, and combined proof target. - (Some(solutions), solutions_root, combined_proof_target) + // Check if there are any valid solutions. + match valid_candidate_solutions.is_empty() { + true => (None, Field::::zero(), 0u128), + false => { + // Construct the solutions. + let solutions = CoinbaseSolution::new(valid_candidate_solutions)?; + // Compute the solutions root. + let solutions_root = solutions.to_accumulator_point()?; + // Compute the combined proof target. + let combined_proof_target = solutions.to_combined_proof_target()?; + // Output the solutions, solutions root, and combined proof target. + (Some(solutions), solutions_root, combined_proof_target) + } + } } };