Misc cleanup

This commit is contained in:
Luke Parker 2022-10-16 09:16:44 -04:00
parent c53c15fd95
commit a0bc9dc3e5
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
3 changed files with 8 additions and 22 deletions

View file

@ -124,15 +124,18 @@ impl<N: Network + 'static> TendermintMachine<N> {
// 11-13
async fn round(&mut self, round: Round) {
// Clear timeouts
self.timeouts = HashMap::new();
dbg!(round);
// Correct the start time
for _ in self.round.0 .. round.0 {
self.start_time = self.timeout(Step::Precommit);
}
// Clear timeouts
self.timeouts = HashMap::new();
self.round = round;
self.step = Step::Propose;
self.round_propose().await;
}
@ -151,6 +154,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
}
// 10
#[allow(clippy::new_ret_no_self)]
pub fn new(
network: N,
proposer: N::ValidatorId,
@ -284,6 +288,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
}
// Else, check if we need to jump ahead
#[allow(clippy::comparison_chain)]
if msg.round.0 < self.round.0 {
return Ok(None);
} else if msg.round.0 > self.round.0 {

View file

@ -72,24 +72,6 @@ impl<N: Network> MessageLog<N> {
weight
}
// Get the participation in a given round for a given step.
pub(crate) fn participation(&self, round: Round, step: Step) -> u64 {
let (participating, _) = self.message_instances(
round,
match step {
Step::Propose => panic!("Checking for participation on Propose"),
Step::Prevote => Data::Prevote(None),
Step::Precommit => Data::Precommit(None),
},
);
participating
}
// Check if there's been a BFT level of participation
pub(crate) fn has_participation(&self, round: Round, step: Step) -> bool {
self.participation(round, step) >= self.weights.threshold()
}
// Check if consensus has been reached on a specific piece of data
pub(crate) fn has_consensus(&self, round: Round, data: Data<N::Block>) -> bool {
let (_, weight) = self.message_instances(round, data);

View file

@ -1,6 +1,6 @@
use std::sync::Arc;
use tokio::sync::{RwLock, mpsc};
use tokio::sync::RwLock;
use tendermint_machine::{ext::*, Message, TendermintMachine, TendermintHandle};
@ -87,7 +87,6 @@ impl TestNetwork {
));
}
}
dbg!("Created all machines");
arc
}
}