Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change BreatheBlockInterval config to time period #1005

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading