mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 21:49:26 +00:00
Slight doc changes
Also flattens the message handling function by replacing an if containing all following code in the function with an early return for the else case.
This commit is contained in:
@@ -381,7 +381,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns Ok(true) if this was a Precommit which had its signature validated
|
// Returns Ok(true) if this was a Precommit which had its signature validated
|
||||||
// Returns Ok(false) if the signature wasn't validated yet
|
// Returns Ok(false) if it wasn't a Precommit or the signature wasn't validated yet
|
||||||
// Returns Err if the signature was invalid
|
// Returns Err if the signature was invalid
|
||||||
fn verify_precommit_signature(
|
fn verify_precommit_signature(
|
||||||
&self,
|
&self,
|
||||||
@@ -469,6 +469,8 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
} else {
|
} else {
|
||||||
// Remove the message so it isn't counted towards forming a commit/included in one
|
// Remove the message so it isn't counted towards forming a commit/included in one
|
||||||
// This won't remove the fact the precommitted for this block hash in the MessageLog
|
// This won't remove the fact the precommitted for this block hash in the MessageLog
|
||||||
|
// TODO: Don't even log these in the first place until we jump, preventing needing
|
||||||
|
// to do this in the first place
|
||||||
self
|
self
|
||||||
.block
|
.block
|
||||||
.log
|
.log
|
||||||
@@ -518,10 +520,16 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
self.block.round_mut().set_timeout(Step::Precommit);
|
self.block.round_mut().set_timeout(Step::Precommit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All further operations require actually having the proposal in question
|
||||||
let proposer = self.weights.proposer(self.block.number, self.block.round().number);
|
let proposer = self.weights.proposer(self.block.number, self.block.round().number);
|
||||||
if let Some(Data::Proposal(vr, block)) =
|
let (vr, block) = if let Some(Data::Proposal(vr, block)) =
|
||||||
self.block.log.get(self.block.round().number, proposer, Step::Propose)
|
self.block.log.get(self.block.round().number, proposer, Step::Propose)
|
||||||
{
|
{
|
||||||
|
(vr, block)
|
||||||
|
} else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
|
||||||
// 22-33
|
// 22-33
|
||||||
if self.block.round().step == Step::Propose {
|
if self.block.round().step == Step::Propose {
|
||||||
// Delay error handling (triggering a slash) until after we vote.
|
// Delay error handling (triggering a slash) until after we vote.
|
||||||
@@ -560,7 +568,11 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
self.broadcast(Data::Prevote(vote));
|
self.broadcast(Data::Prevote(vote));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
} else if self
|
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
if self
|
||||||
.block
|
.block
|
||||||
.valid
|
.valid
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -569,11 +581,10 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
{
|
{
|
||||||
// 36-43
|
// 36-43
|
||||||
|
|
||||||
// The run once condition is implemented above. Sinve valid will always be set, it not
|
// The run once condition is implemented above. Since valid will always be set by this, it
|
||||||
// being set, or only being set historically, means this has yet to be run
|
// not being set, or only being set historically, means this has yet to be run
|
||||||
|
|
||||||
if self.block.log.has_consensus(self.block.round().number, Data::Prevote(Some(block.id())))
|
if self.block.log.has_consensus(self.block.round().number, Data::Prevote(Some(block.id()))) {
|
||||||
{
|
|
||||||
match self.network.validate(block).await {
|
match self.network.validate(block).await {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(BlockError::Temporal) => (),
|
Err(BlockError::Temporal) => (),
|
||||||
@@ -593,8 +604,6 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
))
|
))
|
||||||
.await,
|
.await,
|
||||||
))));
|
))));
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user