check if commit msgs has reached consensus return @ consensused proposer @ consensused for empty commit
(commitMsgs []*blockCommitMsg, C int, N int)
| 320 | // @ consensused for empty commit |
| 321 | // |
| 322 | func getCommitConsensus(commitMsgs []*blockCommitMsg, C int, N int) (uint32, bool) { |
| 323 | emptyCommitCount := 0 |
| 324 | emptyCommit := false |
| 325 | signCount := make(map[uint32]map[uint32]int) |
| 326 | for _, c := range commitMsgs { |
| 327 | if c.CommitForEmpty { |
| 328 | emptyCommitCount++ |
| 329 | if emptyCommitCount > C && !emptyCommit { |
| 330 | C += 1 |
| 331 | emptyCommit = true |
| 332 | } |
| 333 | } |
| 334 | if _, present := signCount[c.BlockProposer]; !present { |
| 335 | signCount[c.BlockProposer] = make(map[uint32]int) |
| 336 | } |
| 337 | signCount[c.BlockProposer][c.Committer] += 1 |
| 338 | for endorser := range c.EndorsersSig { |
| 339 | signCount[c.BlockProposer][endorser] += 1 |
| 340 | } |
| 341 | if len(signCount[c.BlockProposer])+1 >= N-(N-1)/3 { |
| 342 | return c.BlockProposer, emptyCommit |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | return math.MaxUint32, false |
| 347 | } |
| 348 | |
| 349 | func (self *Server) findBlockProposal(blkNum uint32, proposer uint32, forEmpty bool) *blockProposalMsg { |
| 350 | for _, p := range self.blockPool.getBlockProposals(blkNum) { |
no outgoing calls