(evtType TimerEventType)
| 155 | } |
| 156 | |
| 157 | func (self *EventTimer) getEventTimeout(evtType TimerEventType) time.Duration { |
| 158 | switch evtType { |
| 159 | case EventProposeBlockTimeout: |
| 160 | return makeProposalTimeout |
| 161 | case EventPropose2ndBlockTimeout: |
| 162 | return make2ndProposalTimeout |
| 163 | case EventEndorseBlockTimeout: |
| 164 | return endorseBlockTimeout |
| 165 | case EventEndorseEmptyBlockTimeout: |
| 166 | return endorseBlockTimeout |
| 167 | case EventCommitBlockTimeout: |
| 168 | return commitBlockTimeout |
| 169 | case EventPeerHeartbeat: |
| 170 | return peerHandshakeTimeout |
| 171 | case EventProposalBackoff: |
| 172 | rank := self.server.getProposerRank(self.server.GetCurrentBlockNo(), self.server.Index) |
| 173 | if rank >= 0 { |
| 174 | d := int64(rank+1) * int64(make2ndProposalTimeout) / 3 |
| 175 | return time.Duration(d) |
| 176 | } |
| 177 | return time.Duration(100 * time.Second) |
| 178 | case EventRandomBackoff: |
| 179 | d := (rand.Int63n(100) + 50) * int64(endorseBlockTimeout) / 10 |
| 180 | return time.Duration(d) |
| 181 | case EventTxPool: |
| 182 | return txPooltimeout |
| 183 | case EventTxBlockTimeout: |
| 184 | return zeroTxBlockTimeout |
| 185 | } |
| 186 | |
| 187 | return 0 |
| 188 | } |
| 189 | |
| 190 | // |
| 191 | // internal helper, should call with lock held |
no test coverage detected