(&mut self, bft_msg: BftMsg)
| 867 | } |
| 868 | |
| 869 | fn process(&mut self, bft_msg: BftMsg) { |
| 870 | match bft_msg { |
| 871 | BftMsg::Proposal(proposal) => { |
| 872 | if self.step <= Step::ProposeWait { |
| 873 | if let Some(prop) = self.handle_proposal(proposal) { |
| 874 | self.set_proposal(prop); |
| 875 | if self.step == Step::ProposeWait { |
| 876 | self.change_to_step(Step::Prevote); |
| 877 | self.transmit_prevote(); |
| 878 | if self.check_prevote_count() { |
| 879 | self.change_to_step(Step::PrevoteWait); |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | } |
| 884 | } |
| 885 | BftMsg::Vote(vote) => { |
| 886 | if vote.vote_type == VoteType::Prevote { |
| 887 | if self.step <= Step::PrevoteWait { |
| 888 | let _ = self.try_save_vote(vote); |
| 889 | if self.step >= Step::Prevote && self.check_prevote_count() { |
| 890 | self.change_to_step(Step::PrevoteWait); |
| 891 | } |
| 892 | } |
| 893 | } else if vote.vote_type == VoteType::Precommit { |
| 894 | if self.step < Step::Precommit { |
| 895 | let _ = self.try_save_vote(vote.clone()); |
| 896 | } |
| 897 | if (self.step == Step::Precommit || self.step == Step::PrecommitWait) |
| 898 | && self.try_save_vote(vote) |
| 899 | { |
| 900 | let precommit_result = self.check_precommit_count(); |
| 901 | |
| 902 | if precommit_result == PRECOMMIT_ON_NOTHING { |
| 903 | // only receive +2/3 precommits might lead BFT to PrecommitWait |
| 904 | self.change_to_step(Step::PrecommitWait); |
| 905 | } |
| 906 | |
| 907 | if precommit_result == PRECOMMIT_ON_NIL { |
| 908 | // receive +2/3 on nil, goto next round directly |
| 909 | if self.lock_status.is_none() { |
| 910 | self.proposal = None; |
| 911 | } |
| 912 | self.goto_next_round(); |
| 913 | self.new_round_start(); |
| 914 | } |
| 915 | if precommit_result == PRECOMMIT_ON_PROPOSAL { |
| 916 | // receive +2/3 on a proposal, try to commit |
| 917 | self.change_to_step(Step::Commit); |
| 918 | self.proc_commit(); |
| 919 | self.change_to_step(Step::CommitWait); |
| 920 | } |
| 921 | } |
| 922 | } else { |
| 923 | error!("Invalid Vote Type!"); |
| 924 | } |
| 925 | } |
| 926 | BftMsg::Feed(feed) => { |
no test coverage detected