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

Method setProposalCommitted

consensus/vbft/block_pool.go:418–447  ·  view source on GitHub ↗
(proposal *blockProposalMsg, forEmpty bool)

Source from the content-addressed store, hash-verified

416}
417
418func (pool *BlockPool) setProposalCommitted(proposal *blockProposalMsg, forEmpty bool) error {
419 pool.lock.Lock()
420 defer pool.lock.Unlock()
421
422 // check candidate Info
423 blkNum := proposal.GetBlockNum()
424 c := pool.candidateBlocks[blkNum]
425 if c == nil {
426 return fmt.Errorf("non-candidates for block %d yet when set commit", blkNum)
427 }
428
429 // check if has committed
430 if c.CommittedProposal != nil || c.CommittedEmptyProposal != nil {
431 return fmt.Errorf("had committed for block %d", blkNum)
432 }
433
434 if forEmpty {
435 if c.CommittedEmptyProposal != nil && c.CommittedEmptyProposal.Block.getProposer() != proposal.Block.getProposer() {
436 return fmt.Errorf("had committed for empty block %d (%d)", blkNum, c.CommittedEmptyProposal.Block.getProposer())
437 }
438 c.CommittedEmptyProposal = proposal
439 } else {
440 if c.CommittedProposal != nil && c.CommittedProposal.Block.getProposer() != proposal.Block.getProposer() {
441 return fmt.Errorf("had committed for block %d (%d)", blkNum, c.CommittedProposal.Block.getProposer())
442 }
443 c.CommittedProposal = proposal
444 }
445
446 return nil
447}
448
449//
450// add commit msg to CandidateInfo

Callers 1

commitBlockMethod · 0.80

Calls 3

ErrorfMethod · 0.80
getProposerMethod · 0.80
GetBlockNumMethod · 0.65

Tested by

no test coverage detected