mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-12 09:26:51 +00:00
Misc cleanup
This commit is contained in:
parent
c53c15fd95
commit
a0bc9dc3e5
3 changed files with 8 additions and 22 deletions
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue