Skip to content

Commit

Permalink
consensus: rename VoterWithCredits to Voter
Browse files Browse the repository at this point in the history
  • Loading branch information
fed-franz committed Jul 23, 2024
1 parent 1254c94 commit e44e617
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions consensus/src/commons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use node_data::message::{AsyncQueue, Message, Payload};
use node_data::StepName;
use tracing::error;

use crate::operations::VoterWithCredits;
use crate::operations::Voter;

pub type TimeoutSet = HashMap<StepName, Duration>;

Expand All @@ -36,7 +36,7 @@ pub struct RoundUpdate {
seed: Seed,
hash: [u8; 32],
att: Attestation,
att_voters: Vec<VoterWithCredits>,
att_voters: Vec<Voter>,
timestamp: u64,

pub base_timeouts: TimeoutSet,
Expand All @@ -48,7 +48,7 @@ impl RoundUpdate {
secret_key: BlsSecretKey,
tip_header: &Header,
base_timeouts: TimeoutSet,
att_voters: Vec<VoterWithCredits>,
att_voters: Vec<Voter>,
) -> Self {
let round = tip_header.height + 1;
RoundUpdate {
Expand Down Expand Up @@ -80,7 +80,7 @@ impl RoundUpdate {
self.timestamp
}

pub fn att_voters(&self) -> &Vec<VoterWithCredits> {
pub fn att_voters(&self) -> &Vec<Voter> {
&self.att_voters
}
}
Expand Down
8 changes: 4 additions & 4 deletions consensus/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use thiserror::Error;

pub type StateRoot = [u8; 32];
pub type EventHash = [u8; 32];
pub type VoterWithCredits = (BlsPublicKey, usize);
pub type Voter = (BlsPublicKey, usize);

#[derive(Debug, Error)]
pub enum Error {
Expand Down Expand Up @@ -53,7 +53,7 @@ pub struct CallParams {
pub block_gas_limit: u64,
pub generator_pubkey: node_data::bls::PublicKey,
pub to_slash: Vec<Slash>,
pub voters_pubkey: Option<Vec<VoterWithCredits>>,
pub voters_pubkey: Option<Vec<Voter>>,
}

#[derive(Default)]
Expand Down Expand Up @@ -86,7 +86,7 @@ pub trait Operations: Send + Sync {
&self,
candidate_header: &Header,
disable_winning_att_check: bool,
) -> Result<(u8, Vec<VoterWithCredits>, Vec<VoterWithCredits>), Error>;
) -> Result<(u8, Vec<Voter>, Vec<Voter>), Error>;

async fn verify_faults(
&self,
Expand All @@ -97,7 +97,7 @@ pub trait Operations: Send + Sync {
async fn verify_state_transition(
&self,
blk: &Block,
voters: &[VoterWithCredits],
voters: &[Voter],
) -> Result<VerificationOutput, Error>;

async fn execute_state_transition(
Expand Down
4 changes: 2 additions & 2 deletions consensus/src/proposal/block_generator.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 crate::commons::{get_current_timestamp, RoundUpdate};
use crate::operations::{CallParams, Operations, VoterWithCredits};
use crate::operations::{CallParams, Operations, Voter};
use node_data::ledger::{
to_str, Attestation, Block, Fault, IterationsInfo, Seed, Slash,
};
Expand Down Expand Up @@ -90,7 +90,7 @@ impl<T: Operations> Generator<T> {
iteration: u8,
failed_iterations: IterationsInfo,
faults: &[Fault],
voters: &[VoterWithCredits],
voters: &[Voter],
) -> Result<Block, crate::operations::Error> {
let to_slash =
Slash::from_iterations_and_faults(&failed_iterations, faults)?;
Expand Down
4 changes: 2 additions & 2 deletions consensus/src/validation/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use crate::commons::{ConsensusError, Database, RoundUpdate};
use crate::config;
use crate::execution_ctx::ExecutionCtx;
use crate::operations::{Operations, VoterWithCredits};
use crate::operations::{Operations, Voter};
use crate::validation::handler;
use anyhow::anyhow;
use node_data::ledger::{to_str, Block};
Expand Down Expand Up @@ -140,7 +140,7 @@ impl<T: Operations + 'static> ValidationStep<T> {

async fn call_vst(
candidate: &Block,
voters: &[VoterWithCredits],
voters: &[Voter],
executor: &Arc<T>,
) -> anyhow::Result<()> {
match executor.verify_state_transition(candidate, voters).await {
Expand Down

0 comments on commit e44e617

Please sign in to comment.