(proposal *blockProposalMsg, forEmpty bool)
| 416 | } |
| 417 | |
| 418 | func (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 |
no test coverage detected