Skip to content

Commit

Permalink
added comment
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed May 11, 2023
1 parent 828a32d commit a4795d0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion datastore/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,12 @@ func (r *RedisCache) CheckAndSetLastSlotAndHashDelivered(slot uint64, hash strin
return err
}

// slot in the past, reject request
if slot < lastSlotDelivered {
return ErrPastSlotAlreadyDelivered
}

// current slot, reject request if hash is different
if slot == lastSlotDelivered {
lastHashDelivered, err := tx.Get(context.Background(), r.keyLastHashDelivered).Result()
if err != nil && !errors.Is(err, redis.Nil) {
Expand All @@ -309,7 +311,7 @@ func (r *RedisCache) CheckAndSetLastSlotAndHashDelivered(slot uint64, hash strin
return err
}

return r.client.Watch(context.Background(), txf, r.keyLastSlotDelivered)
return r.client.Watch(context.Background(), txf, r.keyLastSlotDelivered, r.keyLastHashDelivered)
}

func (r *RedisCache) GetLastSlotDelivered() (slot uint64, err error) {
Expand Down

0 comments on commit a4795d0

Please sign in to comment.