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:
Luke Parker
2022-11-13 18:33:26 -05:00
parent 0b8181b912
commit 48b4b685ca

View File

@@ -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(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
fn verify_precommit_signature(
&self,
@@ -469,6 +469,8 @@ impl<N: Network + 'static> TendermintMachine<N> {
} else {
// 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
// TODO: Don't even log these in the first place until we jump, preventing needing
// to do this in the first place
self
.block
.log
@@ -518,10 +520,16 @@ impl<N: Network + 'static> TendermintMachine<N> {
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);
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)
{
(vr, block)
} else {
return Ok(None);
};
// 22-33
if self.block.round().step == Step::Propose {
// 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));
return err;
}
} else if self
return Ok(None);
}
if self
.block
.valid
.as_ref()
@@ -569,11 +581,10 @@ impl<N: Network + 'static> TendermintMachine<N> {
{
// 36-43
// The run once condition is implemented above. Sinve valid will always be set, it not
// being set, or only being set historically, means this has yet to be run
// The run once condition is implemented above. Since valid will always be set by this, it
// 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 {
Ok(_) => (),
Err(BlockError::Temporal) => (),
@@ -593,8 +604,6 @@ impl<N: Network + 'static> TendermintMachine<N> {
))
.await,
))));
return Ok(None);
}
}
}
}