add more gossip if step is stuck

This commit is contained in:
keorn 2016-12-02 13:37:49 +00:00
parent e0f2fac441
commit 91099f62c9
2 changed files with 16 additions and 7 deletions

View File

@ -78,38 +78,42 @@ impl IoHandler<Step> for TransitionHandler {
Step::Propose => { Step::Propose => {
trace!(target: "poa", "timeout: Propose timeout."); trace!(target: "poa", "timeout: Propose timeout.");
set_timeout(io, engine.our_params.timeouts.prevote); set_timeout(io, engine.our_params.timeouts.prevote);
Step::Prevote Some(Step::Prevote)
}, },
Step::Prevote if engine.has_enough_any_votes() => { Step::Prevote if engine.has_enough_any_votes() => {
trace!(target: "poa", "timeout: Prevote timeout."); trace!(target: "poa", "timeout: Prevote timeout.");
set_timeout(io, engine.our_params.timeouts.precommit); set_timeout(io, engine.our_params.timeouts.precommit);
Step::Precommit Some(Step::Precommit)
}, },
Step::Prevote => { Step::Prevote => {
trace!(target: "poa", "timeout: Prevote timeout without enough votes."); trace!(target: "poa", "timeout: Prevote timeout without enough votes.");
set_timeout(io, engine.our_params.timeouts.prevote); set_timeout(io, engine.our_params.timeouts.prevote);
Step::Prevote engine.broadcast_old_messages();
None
}, },
Step::Precommit if engine.has_enough_any_votes() => { Step::Precommit if engine.has_enough_any_votes() => {
trace!(target: "poa", "timeout: Precommit timeout."); trace!(target: "poa", "timeout: Precommit timeout.");
set_timeout(io, engine.our_params.timeouts.propose); set_timeout(io, engine.our_params.timeouts.propose);
engine.increment_round(1); engine.increment_round(1);
Step::Propose Some(Step::Propose)
}, },
Step::Precommit => { Step::Precommit => {
trace!(target: "poa", "timeout: Precommit timeout without enough votes."); trace!(target: "poa", "timeout: Precommit timeout without enough votes.");
set_timeout(io, engine.our_params.timeouts.precommit); set_timeout(io, engine.our_params.timeouts.precommit);
Step::Precommit engine.broadcast_old_messages();
None
}, },
Step::Commit => { Step::Commit => {
trace!(target: "poa", "timeout: Commit timeout."); trace!(target: "poa", "timeout: Commit timeout.");
set_timeout(io, engine.our_params.timeouts.propose); set_timeout(io, engine.our_params.timeouts.propose);
engine.reset_round(); engine.reset_round();
Step::Propose Some(Step::Propose)
}, },
}; };
engine.to_step(next_step) if let Some(s) = next_step {
engine.to_step(s)
}
} }
} }
} }

View File

@ -126,6 +126,11 @@ impl VoteCollector {
} }
n n
} }
pub fn get_older_than(&self, message: &ConsensusMessage) -> Vec<Bytes> {
let guard = self.votes.read();
guard.keys().take_while(|m| *m <= message).map(|m| ::rlp::encode(m).to_vec()).collect()
}
} }
#[cfg(test)] #[cfg(test)]