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

Method isProposer

consensus/vbft/node_utils.go:75–93  ·  view source on GitHub ↗

the first proposer as leader-proposer, all other proposer as 2nd-proposer before propose-timeout, only proposal from leader-proposer is accepted

(blockNum uint32, peerIdx uint32)

Source from the content-addressed store, hash-verified

73// before propose-timeout, only proposal from leader-proposer is accepted
74//
75func (self *Server) isProposer(blockNum uint32, peerIdx uint32) bool {
76 self.metaLock.RLock()
77 defer self.metaLock.RUnlock()
78
79 {
80 if peerIdx == self.Index && !isActive(self.getState()) {
81 return false
82 }
83 // the first active proposer
84 for _, id := range self.currentParticipantConfig.Proposers {
85 if self.isPeerAlive(id, blockNum) {
86 return peerIdx == id
87 }
88 }
89 }
90
91 // TODO: proposer check for non-current block
92 return false
93}
94
95func (self *Server) is2ndProposer(blockNum uint32, peerIdx uint32) bool {
96 rank := self.getProposerRank(blockNum, peerIdx)

Callers 6

startNewRoundMethod · 0.95
startNewProposalMethod · 0.95
processMsgEventMethod · 0.95
handleProposalTimeoutMethod · 0.95
catchConsensusMethod · 0.95
TestIsProposerFunction · 0.80

Calls 3

getStateMethod · 0.95
isPeerAliveMethod · 0.95
isActiveFunction · 0.85

Tested by 1

TestIsProposerFunction · 0.64