(ctx context.Context, key string, c Constraint, e Entry)
| 343 | } |
| 344 | |
| 345 | func (s *Store) commitWithConstraint(ctx context.Context, key string, c Constraint, e Entry) error { |
| 346 | return s.commit(ctx, func() error { |
| 347 | oldEntry, ok := s.table[key] |
| 348 | if !ok { |
| 349 | return ErrNoSuchKey |
| 350 | } |
| 351 | if c != nil && !c(oldEntry) { |
| 352 | return ErrConstraint |
| 353 | } |
| 354 | return nil |
| 355 | }, e) |
| 356 | } |
| 357 | |
| 358 | func (s *Store) commit(ctx context.Context, fn func() error, entries ...Entry) error { |
| 359 | serializer := bsupbytes.NewSerializer() |