| 1 | package checkpoint |
| 2 | |
| 3 | import "reasonix/internal/provider" |
| 4 | |
| 5 | // RecoveryIdentity correlates the first writer's preimages with its durable |
| 6 | // action record. It does not claim that the external effect committed. |
| 7 | type RecoveryIdentity struct { |
| 8 | Action provider.ActionIdentity `json:"action"` |
| 9 | TranscriptDigest string `json:"transcriptDigest"` |
| 10 | } |
| 11 | |
| 12 | func (s *Store) BindRecoveryIdentity(identity RecoveryIdentity) error { |
| 13 | if s == nil { |
| 14 | return nil |
| 15 | } |
| 16 | s.mu.Lock() |
| 17 | defer s.mu.Unlock() |
| 18 | if s.cur == nil || s.cur.Recovery != nil { |
| 19 | return nil |
| 20 | } |
| 21 | s.cur.Recovery = &identity |
| 22 | if err := s.persist(s.cur); err != nil { |
| 23 | s.cur.Recovery = nil |
| 24 | return err |
| 25 | } |
| 26 | return nil |
| 27 | } |
| 28 |