Skip to content

Commit

Permalink
Merge pull request #2120 from AleoHQ/feat/empty-solutions
Browse files Browse the repository at this point in the history
Handle empty solutions case after filter
  • Loading branch information
howardwu authored Oct 25, 2023
2 parents 10dcbdf + 3b642a0 commit c0cfe70
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions ledger/src/advance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,20 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
.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::<N>::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)
}
}
}
};

Expand Down

0 comments on commit c0cfe70

Please sign in to comment.