mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Misc cleanup
This commit is contained in:
@@ -124,15 +124,18 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
|
|
||||||
// 11-13
|
// 11-13
|
||||||
async fn round(&mut self, round: Round) {
|
async fn round(&mut self, round: Round) {
|
||||||
// Clear timeouts
|
dbg!(round);
|
||||||
self.timeouts = HashMap::new();
|
|
||||||
|
|
||||||
// Correct the start time
|
// Correct the start time
|
||||||
for _ in self.round.0 .. round.0 {
|
for _ in self.round.0 .. round.0 {
|
||||||
self.start_time = self.timeout(Step::Precommit);
|
self.start_time = self.timeout(Step::Precommit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear timeouts
|
||||||
|
self.timeouts = HashMap::new();
|
||||||
|
|
||||||
self.round = round;
|
self.round = round;
|
||||||
|
self.step = Step::Propose;
|
||||||
self.round_propose().await;
|
self.round_propose().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +154,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 10
|
// 10
|
||||||
|
#[allow(clippy::new_ret_no_self)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
network: N,
|
network: N,
|
||||||
proposer: N::ValidatorId,
|
proposer: N::ValidatorId,
|
||||||
@@ -284,6 +288,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Else, check if we need to jump ahead
|
// Else, check if we need to jump ahead
|
||||||
|
#[allow(clippy::comparison_chain)]
|
||||||
if msg.round.0 < self.round.0 {
|
if msg.round.0 < self.round.0 {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
} else if msg.round.0 > self.round.0 {
|
} else if msg.round.0 > self.round.0 {
|
||||||
|
|||||||
@@ -72,24 +72,6 @@ impl<N: Network> MessageLog<N> {
|
|||||||
weight
|
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
|
// 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 {
|
pub(crate) fn has_consensus(&self, round: Round, data: Data<N::Block>) -> bool {
|
||||||
let (_, weight) = self.message_instances(round, data);
|
let (_, weight) = self.message_instances(round, data);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use tokio::sync::{RwLock, mpsc};
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use tendermint_machine::{ext::*, Message, TendermintMachine, TendermintHandle};
|
use tendermint_machine::{ext::*, Message, TendermintMachine, TendermintHandle};
|
||||||
|
|
||||||
@@ -87,7 +87,6 @@ impl TestNetwork {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbg!("Created all machines");
|
|
||||||
arc
|
arc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user