Skip to content

Commit

Permalink
Simplify conditional logic from review
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon committed Jun 20, 2022
1 parent 996d473 commit b4befe4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions x/epochs/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) {
logger := k.Logger(ctx)

// Has it not started, and is the block time > initial epoch start time
shouldInitialEpochStart := !epochInfo.EpochCountingStarted && !epochInfo.StartTime.After(ctx.BlockTime())
// If blocktime < initial epoch start time, return
if ctx.BlockTime().Before(epochInfo.StartTime) {
return
}
// if epoch counting hasn't started, signal we need to start.
shouldInitialEpochStart := !epochInfo.EpochCountingStarted

epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration)
shouldEpochStart := (ctx.BlockTime().After(epochEndTime) && !epochInfo.StartTime.After(ctx.BlockTime())) || shouldInitialEpochStart
shouldEpochStart := (ctx.BlockTime().After(epochEndTime)) || shouldInitialEpochStart

if !shouldEpochStart {
return false
Expand Down

0 comments on commit b4befe4

Please sign in to comment.