Skip to content

Commit

Permalink
add invariant to ensure we are processing unstarted tx
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaidashenko committed Dec 13, 2023
1 parent da96c05 commit 251d99c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/txmgr/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ func (eb *Broadcaster[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) hand
}

func (eb *Broadcaster[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) handleUnstartedTx(ctx context.Context, etx *txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) (error, bool) {
if etx.State != TxUnstarted {
return fmt.Errorf("invariant violation: expected transaction %v to be unstarted, it was %s", etx.ID, etx.State), false
}

attempt, _, _, retryable, err := eb.NewTxAttempt(ctx, *etx, eb.lggr)
if err != nil {
return fmt.Errorf("processUnstartedTxs failed on NewAttempt: %w", err), retryable
Expand Down

0 comments on commit 251d99c

Please sign in to comment.