Refactor <V, B> to type V, type B

This commit is contained in:
Luke Parker
2022-10-16 03:55:39 -04:00
parent a5f1ddaf1b
commit f79321233d
4 changed files with 43 additions and 26 deletions

View File

@@ -3,12 +3,6 @@ use ext::*;
mod message_log;
// Type aliases which are distinct according to the type system
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub(crate) struct BlockNumber(u32);
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub(crate) struct Round(u32);
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
enum Step {
Propose,
@@ -58,13 +52,6 @@ use tokio::{
sync::mpsc,
};
type ValidatorId = u16;
const VALIDATORS: ValidatorId = 5;
fn proposer(number: u32, round: u32) -> ValidatorId {
ValidatorId::try_from((number + round) % u32::try_from(VALIDATORS).unwrap()).unwrap()
}
#[derive(Debug)]
struct TendermintMachine {
proposer: ValidatorId,