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

Method newBlockCommitment

consensus/vbft/block_pool.go:452–490  ·  view source on GitHub ↗

add commit msg to CandidateInfo

(msg *blockCommitMsg)

Source from the content-addressed store, hash-verified

450// add commit msg to CandidateInfo
451//
452func (pool *BlockPool) newBlockCommitment(msg *blockCommitMsg) error {
453 pool.lock.Lock()
454 defer pool.lock.Unlock()
455
456 blkNum := msg.GetBlockNum()
457 candidate := pool.getCandidateInfoLocked(blkNum)
458
459 // check dup-commit
460 for _, c := range candidate.CommitMsgs {
461 if c.Committer == msg.Committer {
462 if bytes.Compare(c.CommitBlockHash[:], msg.CommitBlockHash[:]) == 0 {
463 return nil
464 }
465 // one committer, one commit
466 return errDupCommit
467 }
468 }
469
470 // add all endorse sigs
471 for endorser, sig := range msg.EndorsersSig {
472 eSig := &CandidateEndorseSigInfo{
473 EndorsedProposer: msg.BlockProposer,
474 Signature: sig,
475 ForEmpty: msg.CommitForEmpty,
476 }
477 pool.addBlockEndorsementLocked(blkNum, endorser, eSig, false)
478 }
479
480 // add committer sig
481 pool.addBlockEndorsementLocked(blkNum, msg.Committer, &CandidateEndorseSigInfo{
482 EndorsedProposer: msg.BlockProposer,
483 Signature: msg.CommitterSig,
484 ForEmpty: msg.CommitForEmpty,
485 }, true)
486
487 // add msg to commit-msgs
488 candidate.CommitMsgs = append(candidate.CommitMsgs, msg)
489 return nil
490}
491
492//
493// check if has reached consensus on block-commit

Callers 3

startNewRoundMethod · 0.80
processMsgEventMethod · 0.80
actionLoopMethod · 0.80

Calls 3

GetBlockNumMethod · 0.65

Tested by

no test coverage detected