Skip to content

Commit 0ee371f

Browse files
committed
fix prevent too early case
1 parent 00c589e commit 0ee371f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

grogu/signaller/signaller.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,14 @@ func (h *Signaller) shouldUpdatePrice(
286286
newPrice uint64,
287287
now time.Time,
288288
) bool {
289+
// thresholdTime is the time when the price can be updated.
290+
// add TimeBuffer to make sure the thresholdTime is not too early.
291+
thresholdTime := time.Unix(valPrice.Timestamp+h.params.CooldownTime+TimeBuffer, 0)
292+
293+
if thresholdTime.After(now) {
294+
return false
295+
}
296+
289297
// Check if the price is past the assigned time, if it is, add it to the list of prices to update
290298
assignedTime := calculateAssignedTime(
291299
h.valAddress,
@@ -295,11 +303,7 @@ func (h *Signaller) shouldUpdatePrice(
295303
h.distributionStartPercentage,
296304
)
297305

298-
// thresholdTime is the time when the price can be updated.
299-
// add TimeBuffer to make sure the thresholdTime is not too early.
300-
thresholdTime := time.Unix(valPrice.Timestamp+h.params.CooldownTime+TimeBuffer, 0)
301-
302-
if thresholdTime.Before(now) && assignedTime.Before(now) {
306+
if assignedTime.Before(now) {
303307
return true
304308
}
305309

0 commit comments

Comments
 (0)