From b4befe4f3eb97ebb477323234b910c4afafab9b7 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 20 Jun 2022 15:53:01 -0500 Subject: [PATCH] Simplify conditional logic from review --- x/epochs/abci.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/x/epochs/abci.go b/x/epochs/abci.go index 5406d89afe9..884d05e2339 100644 --- a/x/epochs/abci.go +++ b/x/epochs/abci.go @@ -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