MCPcopy Create free account
hub / github.com/cryptape/bft-rs / check_precommit_count

Method check_precommit_count

src/algorithm.rs:712–747  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

710 }
711
712 fn check_precommit_count(&mut self) -> i8 {
713 if let Some(precommit_set) =
714 self.votes
715 .get_voteset(self.height, self.round, VoteType::Precommit)
716 {
717 let mut tv = if self.cal_all_vote(precommit_set.count) {
718 Duration::new(0, 0)
719 } else {
720 self.params.timer.get_precommit()
721 };
722 if !self.cal_above_threshold(precommit_set.count) {
723 return PRECOMMIT_BELOW_TWO_THIRDS;
724 }
725
726 info!(
727 "Receive over 2/3 precommit at height {:?}, round {:?}",
728 self.height, self.round
729 );
730
731 for (hash, count) in &precommit_set.votes_by_proposal {
732 if self.cal_above_threshold(*count) {
733 if hash.is_empty() {
734 info!("Reach nil consensus, goto next round {:?}", self.round + 1);
735 return PRECOMMIT_ON_NIL;
736 } else {
737 self.set_polc(&hash, &precommit_set, VoteType::Precommit);
738 return PRECOMMIT_ON_PROPOSAL;
739 }
740 }
741 }
742 if self.step == Step::Precommit {
743 self.set_timer(tv, Step::PrecommitWait);
744 }
745 }
746 PRECOMMIT_ON_NOTHING
747 }
748
749 fn proc_commit(&mut self) {
750 let result = self.lock_status.clone().expect("No lock when commit!");

Callers 2

processMethod · 0.80
timeout_processMethod · 0.80

Calls 6

get_votesetMethod · 0.80
cal_all_voteMethod · 0.80
get_precommitMethod · 0.80
cal_above_thresholdMethod · 0.80
set_polcMethod · 0.80
set_timerMethod · 0.80

Tested by

no test coverage detected