From 9d748bd9692c3097913aad7f8fe41cc61fd7612f Mon Sep 17 00:00:00 2001 From: Alexander Tesfamichael Date: Fri, 4 Aug 2023 14:17:24 +0200 Subject: [PATCH] fix(redis): move WasTopBidUpdated to after exec We have several conditions where we don't execute the pipelined commands. Only set the WasTopBidUpdated flag after we execute the pipeline successfully. Do note, if the pipeline fails we may or may not have actually saved the bid. --- datastore/redis.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/datastore/redis.go b/datastore/redis.go index 5b39b9a3d..c18134a28 100644 --- a/datastore/redis.go +++ b/datastore/redis.go @@ -638,8 +638,6 @@ func (r *RedisCache) _updateTopBid(ctx context.Context, tx redis.Pipeliner, stat return state, err } - state.WasTopBidUpdated = state.PrevTopBidValue == nil || state.PrevTopBidValue.Cmp(state.TopBidValue) != 0 - // 6. Finally, update the global top bid value keyTopBidValue := r.keyTopBidValue(slot, parentHash, proposerPubkey) err = tx.Set(context.Background(), keyTopBidValue, state.TopBidValue.String(), expiryBidCache).Err() @@ -648,6 +646,7 @@ func (r *RedisCache) _updateTopBid(ctx context.Context, tx redis.Pipeliner, stat } _, err = tx.Exec(ctx) + state.WasTopBidUpdated = state.PrevTopBidValue == nil || state.PrevTopBidValue.Cmp(state.TopBidValue) != 0 return state, err }