Skip to content

Commit

Permalink
fix(redis): move WasTopBidUpdated to after exec
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alextes committed Aug 4, 2023
1 parent a841455 commit 9d748bd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions datastore/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}

Expand Down

0 comments on commit 9d748bd

Please sign in to comment.