@@ -72,7 +72,7 @@ type LinearTimer struct {
72
72
}
73
73
74
74
// NewLinearTimer constructs a new Linear Timer from the input options and channels
75
- func NewLinearTimer (opts Options , handleTimeoutPropose , handleTimeoutPrevote , handleTimeoutPrecommit func (Timeout )) process. Timer {
75
+ func NewLinearTimer (opts Options , handleTimeoutPropose , handleTimeoutPrevote , handleTimeoutPrecommit func (Timeout )) * LinearTimer {
76
76
return & LinearTimer {
77
77
opts : opts ,
78
78
handleTimeoutPropose : handleTimeoutPropose ,
@@ -86,7 +86,7 @@ func NewLinearTimer(opts Options, handleTimeoutPropose, handleTimeoutPrevote, ha
86
86
func (t * LinearTimer ) TimeoutPropose (height process.Height , round process.Round ) {
87
87
if t .handleTimeoutPropose != nil {
88
88
go func () {
89
- time .Sleep (t .timeoutDuration (height , round ))
89
+ time .Sleep (t .DurationAtHeightAndRound (height , round ))
90
90
t .handleTimeoutPropose (Timeout {MessageType : process .MessageTypePropose , Height : height , Round : round })
91
91
}()
92
92
}
@@ -97,7 +97,7 @@ func (t *LinearTimer) TimeoutPropose(height process.Height, round process.Round)
97
97
func (t * LinearTimer ) TimeoutPrevote (height process.Height , round process.Round ) {
98
98
if t .handleTimeoutPrevote != nil {
99
99
go func () {
100
- time .Sleep (t .timeoutDuration (height , round ))
100
+ time .Sleep (t .DurationAtHeightAndRound (height , round ))
101
101
t .handleTimeoutPrevote (Timeout {MessageType : process .MessageTypePrevote , Height : height , Round : round })
102
102
}()
103
103
}
@@ -108,12 +108,15 @@ func (t *LinearTimer) TimeoutPrevote(height process.Height, round process.Round)
108
108
func (t * LinearTimer ) TimeoutPrecommit (height process.Height , round process.Round ) {
109
109
if t .handleTimeoutPrecommit != nil {
110
110
go func () {
111
- time .Sleep (t .timeoutDuration (height , round ))
111
+ time .Sleep (t .DurationAtHeightAndRound (height , round ))
112
112
t .handleTimeoutPrecommit (Timeout {MessageType : process .MessageTypePrecommit , Height : height , Round : round })
113
113
}()
114
114
}
115
115
}
116
116
117
- func (t * LinearTimer ) timeoutDuration (height process.Height , round process.Round ) time.Duration {
117
+ // DurationAtHeightAndRound returns the duration of the timeout at the given
118
+ // height and round. This is the duration that the other methods will wait
119
+ // before scheduling their respective timeout events.
120
+ func (t * LinearTimer ) DurationAtHeightAndRound (height process.Height , round process.Round ) time.Duration {
118
121
return t .opts .Timeout + t .opts .Timeout * time .Duration (float64 (round )* t .opts .TimeoutScaling )
119
122
}
0 commit comments