If we have the block AND +2/3 commits for it, finalize.
(height int64)
| 1537 | |
| 1538 | // If we have the block AND +2/3 commits for it, finalize. |
| 1539 | func (cs *State) tryFinalizeCommit(height int64) { |
| 1540 | logger := cs.Logger.With("height", height) |
| 1541 | |
| 1542 | if cs.Height != height { |
| 1543 | panic(fmt.Sprintf("tryFinalizeCommit() cs.Height: %v vs height: %v", cs.Height, height)) |
| 1544 | } |
| 1545 | |
| 1546 | blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority() |
| 1547 | if !ok || len(blockID.Hash) == 0 { |
| 1548 | logger.Error("failed attempt to finalize commit; there was no +2/3 majority or +2/3 was for nil") |
| 1549 | return |
| 1550 | } |
| 1551 | |
| 1552 | if !cs.ProposalBlock.HashesTo(blockID.Hash) { |
| 1553 | // TODO: this happens every time if we're not a validator (ugly logs) |
| 1554 | // TODO: ^^ wait, why does it matter that we're a validator? |
| 1555 | logger.Debug( |
| 1556 | "failed attempt to finalize commit; we do not have the commit block", |
| 1557 | "proposal_block", log.NewLazyBlockHash(cs.ProposalBlock), |
| 1558 | "commit_block", blockID.Hash, |
| 1559 | ) |
| 1560 | return |
| 1561 | } |
| 1562 | |
| 1563 | cs.finalizeCommit(height) |
| 1564 | } |
| 1565 | |
| 1566 | // Increment height and goto cstypes.RoundStepNewHeight |
| 1567 | func (cs *State) finalizeCommit(height int64) { |
no test coverage detected