MCPcopy Create free account
hub / github.com/DNAProject/DNA / getCommitConsensus

Function getCommitConsensus

consensus/vbft/node_utils.go:322–347  ·  view source on GitHub ↗

check if commit msgs has reached consensus return @ consensused proposer @ consensused for empty commit

(commitMsgs []*blockCommitMsg, C int, N int)

Source from the content-addressed store, hash-verified

320// @ consensused for empty commit
321//
322func 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
349func (self *Server) findBlockProposal(blkNum uint32, proposer uint32, forEmpty bool) *blockProposalMsg {
350 for _, p := range self.blockPool.getBlockProposals(blkNum) {

Callers 4

TestGetCommitConsensusFunction · 0.85
actionLoopMethod · 0.85
canFastForwardMethod · 0.85
commitDoneMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestGetCommitConsensusFunction · 0.68