(evt *TimerEvent)
| 1649 | } |
| 1650 | |
| 1651 | func (self *Server) processTimerEvent(evt *TimerEvent) error { |
| 1652 | switch evt.evtType { |
| 1653 | case EventProposalBackoff: |
| 1654 | // 1. if endorsed, return |
| 1655 | // 2. if no proposal received, |
| 1656 | // if 2nd proposer, make proposal, start endorse timeout, return |
| 1657 | // else, return (wait proposal timeout) |
| 1658 | // 3. else: |
| 1659 | // if no proposal from leader, return (wait proposal timeout will make endorse anyway) |
| 1660 | // else, return (endorsing on leader-proposal done when received the proposal) |
| 1661 | // |
| 1662 | |
| 1663 | if self.blockPool.endorsedForBlock(evt.blockNum) { |
| 1664 | return nil |
| 1665 | } |
| 1666 | if !isReady(self.getState()) { |
| 1667 | return nil |
| 1668 | } |
| 1669 | proposals := self.blockPool.getBlockProposals(evt.blockNum) |
| 1670 | if len(proposals) == 0 { |
| 1671 | // no proposal received, make proposal, start endorse timeout |
| 1672 | if self.is2ndProposer(evt.blockNum, self.Index) { |
| 1673 | if err := self.makeProposal(evt.blockNum, false); err != nil { |
| 1674 | return fmt.Errorf("failed to make 2nd proposal (%d): %s", evt.blockNum, err) |
| 1675 | } |
| 1676 | } |
| 1677 | } |
| 1678 | |
| 1679 | case EventProposeBlockTimeout: |
| 1680 | // 1. if endorsed, return |
| 1681 | // 2. check proposal from leader, if there is, endorse the proposal, start endorse timeout, return |
| 1682 | // 3. check proposal from 2nd proposer, endorse for first 2nd proposal, start endorse timeout, return |
| 1683 | // 4. if not, random backoff, return |
| 1684 | // |
| 1685 | // then propose for empty block, start 2ndProposal timeout, return |
| 1686 | // |
| 1687 | return self.handleProposalTimeout(evt) |
| 1688 | |
| 1689 | case EventRandomBackoff: |
| 1690 | // 1. if endorsed, return |
| 1691 | // 2. if any valid proposal, endorse on high-priority one (priority from vrf), start endorse timeout, return |
| 1692 | // 3. make empty proposal, broadcast, start 2nd proposal timeout, return |
| 1693 | // |
| 1694 | return self.handleProposalTimeout(evt) |
| 1695 | |
| 1696 | case EventPropose2ndBlockTimeout: |
| 1697 | // 1. if endorsed, return |
| 1698 | // 2. there must some valid proposal, if not, force resync, reset peer neighbours |
| 1699 | // 3. endorse on highest-priority one, start endorse timeout, return |
| 1700 | // |
| 1701 | return self.handleProposalTimeout(evt) |
| 1702 | |
| 1703 | case EventEndorseBlockTimeout: |
| 1704 | // 1. if committed, return |
| 1705 | // 2. check endorse quorum |
| 1706 | // 3. if quorum reached, endorse the proposal, start commit timeout, return |
| 1707 | // 4. broadcast endorse on highest-priority proposal empty, start empty endorse timeout, return |
| 1708 | // |
no test coverage detected