Documentation
¶
Index ¶
- type Store
- func (s *Store) DeleteExpiredEvents(currentBlock uint64) (int64, error)
- func (s *Store) DeleteOldUnsignedEvents(cutoff time.Time) (int64, error)
- func (s *Store) GetBroadcastedSignEvents(limit int) ([]store.Event, error)
- func (s *Store) GetEvent(eventID string) (*store.Event, error)
- func (s *Store) GetInFlightSignEvents() ([]store.Event, error)
- func (s *Store) GetNonExpiredConfirmedEvents(currentBlock, minBlockConfirmation uint64, limit int) ([]store.Event, error)
- func (s *Store) GetSignedSignEvents(limit int) ([]store.Event, error)
- func (s *Store) PersistSignature(eventID string, eventData []byte, signature []byte, signingHash []byte, ...) (bool, error)
- func (s *Store) RecoverInProgressEvents() (int64, int64, error)
- func (s *Store) Update(eventID string, fields map[string]any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides database access for TSS events.
func (*Store) DeleteExpiredEvents ¶ added in v0.0.40
DeleteExpiredEvents hard-deletes events past their ExpiryBlockHeight. Events with ExpiryBlockHeight = 0 (no client-side expiry, e.g., sign events) are not touched. Push chain re-supplies any still-pending event via the event listener — local deletion is safe.
func (*Store) DeleteOldUnsignedEvents ¶ added in v0.0.40
DeleteOldUnsignedEvents hard-deletes unsigned events (status CONFIRMED or IN_PROGRESS) whose CreatedAt is before cutoff. Events past SIGNED are preserved because they carry local commitments (signing_data, broadcasted_tx_hash) that must not be lost. If an event we drop is still pending on push chain, the push chain pending-tx parser will re-populate it on its next poll.
func (*Store) GetBroadcastedSignEvents ¶ added in v0.0.16
GetBroadcastedSignEvents returns SIGN events with status BROADCASTED (for receipt check).
func (*Store) GetInFlightSignEvents ¶ added in v0.0.16
GetInFlightSignEvents returns SIGN events that are currently IN_PROGRESS or SIGNED. BROADCASTED events are excluded because they are already submitted to chain; the pending nonce RPC accounts for them in the mempool, and including them here would make the coordinator wait for the resolver unnecessarily.
func (*Store) GetNonExpiredConfirmedEvents ¶ added in v0.0.16
func (s *Store) GetNonExpiredConfirmedEvents(currentBlock, minBlockConfirmation uint64, limit int) ([]store.Event, error)
GetNonExpiredConfirmedEvents returns confirmed events ready to be processed. Events must be at least minBlockConfirmation blocks old and not past expiry. expiry_block_height = 0 means "no client-side expiry" and matches always.
func (*Store) GetSignedSignEvents ¶ added in v0.0.16
GetSignedSignEvents returns SIGN events with status SIGNED (ready to be broadcast).
func (*Store) PersistSignature ¶ added in v0.0.40
func (s *Store) PersistSignature( eventID string, eventData []byte, signature []byte, signingHash []byte, nonce uint64, fundMigrationAmount *big.Int, ) (bool, error)
PersistSignature merges signing data (signature, hash, nonce, optional fund migration amount) onto an event's event_data and flips its status to SIGNED.
Conditional on current status ∈ {CONFIRMED, IN_PROGRESS} — if the row has already advanced (SIGNED/BROADCASTED/COMPLETED/REVERTED), the write is a no-op. This prevents late writers (a second signature_broadcast arriving after the broadcaster already moved the row to BROADCASTED) from clobbering downstream progress.
Returns (persisted, error). persisted=false when the status guard skipped the write; caller can log and move on.
func (*Store) RecoverInProgressEvents ¶ added in v0.0.40
RecoverInProgressEvents repairs IN_PROGRESS rows on node startup.
Two passes, in order:
- Rows whose event_data already carries a `signing_data` block are flipped to SIGNED — a signature was persisted (via signed ACK or signature_broadcast) but the row's status got clobbered before reaching SIGNED (e.g., the setup-handler racing with PersistSignature).
- The remaining IN_PROGRESS rows are reset to CONFIRMED — they represent genuine mid-session crashes and should be retried.
Returns (signedRecovered, confirmedReset, err).
func (*Store) Update ¶ added in v0.0.16
Update applies field updates to an event by ID. Returns an error if the event is not found.
Example usage:
s.Update(id, map[string]any{"status": store.StatusInProgress})
s.Update(id, map[string]any{"status": store.StatusConfirmed, "block_height": newHeight})
s.Update(id, map[string]any{"broadcasted_tx_hash": txHash})