Skip to content

Commit

Permalink
consensus: change verify_step_vote to return anyhow
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Aug 7, 2024
1 parent 1a6700b commit 5ecf29e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions consensus/src/quorum/verifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use node_data::bls::PublicKey;
use node_data::ledger::{Seed, StepVotes};
use node_data::ledger::{to_str, Seed, StepVotes};
use node_data::message::payload::{self, Vote};
use node_data::message::{ConsensusHeader, StepMessage};
use node_data::{Serializable, StepName};
Expand All @@ -31,7 +31,7 @@ pub async fn verify_step_votes(
committees_set: &RwLock<CommitteeSet<'_>>,
seed: Seed,
step: StepName,
) -> Result<(QuorumResult, Vec<Voter>), StepSigError> {
) -> anyhow::Result<(QuorumResult, Vec<Voter>)> {
let round = header.round;
let iteration = header.iteration;

Expand Down Expand Up @@ -65,11 +65,21 @@ pub async fn verify_step_votes(
let committee = set.get(&cfg).expect("committee to be created");

let (quorum_result, voters) =
verify_votes(header, step, vote, sv, committee)?;
verify_votes(header, step, vote, sv, committee)
.map_err(|e| anyhow::anyhow!(
"invalid {:?}, vote = {:?}, round = {}, iter = {}, seed = {}, sv = {:?}, err = {}",
step,
vote,
header.round,
header.iteration,
to_str(seed.inner()),
sv,
e
))?;

Ok((quorum_result, voters))
}

#[derive(Default)]
pub struct QuorumResult {
pub total: usize,
pub target_quorum: usize,
Expand Down

0 comments on commit 5ecf29e

Please sign in to comment.