Skip to content

Commit

Permalink
fix: change BreatheBlockInterval to time period (#1005)
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 authored Jan 22, 2024
1 parent fa46382 commit 33c826b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ func (app *BNBBeaconChain) isBreatheBlock(height int64, lastBlockTime time.Time,
// lastBlockTime is zero if this blockTime is for the first block (first block doesn't mean height = 1, because after
// state sync from breathe block, the height is breathe block + 1)
if app.baseConfig.BreatheBlockInterval > 0 {
return height%int64(app.baseConfig.BreatheBlockInterval) == 0
return !lastBlockTime.IsZero() && !utils.SamePeriodInUTC(lastBlockTime, blockTime, int64(app.baseConfig.BreatheBlockInterval))
} else {
return !lastBlockTime.IsZero() && !utils.SameDayInUTC(lastBlockTime, blockTime)
}
Expand Down
4 changes: 4 additions & 0 deletions common/utils/times.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ func Now() time.Time {
func SameDayInUTC(first, second time.Time) bool {
return first.Unix()/SecondsPerDay == second.Unix()/SecondsPerDay
}

func SamePeriodInUTC(first, second time.Time, period int64) bool {
return first.Unix()/period == second.Unix()/period
}

0 comments on commit 33c826b

Please sign in to comment.