Skip to content

Commit

Permalink
implement MoveConfirmedMissingReceiptToFatalError
Browse files Browse the repository at this point in the history
  • Loading branch information
poopoothegorilla committed Feb 23, 2024
1 parent 2af9ffa commit 1aa98d3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions common/txmgr/address_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,26 @@ func (as *AddressState[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) MoveIn
}

// MoveConfirmedMissingReceiptToFatalError moves the confirmed missing receipt transaction to the fatal error state.
// If there is no confirmed missing receipt transaction with the given ID, an error is returned.
func (as *AddressState[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) MoveConfirmedMissingReceiptToFatalError(
etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE],
txError null.String,
txID int64, txError null.String,
) error {
as.Lock()
defer as.Unlock()

tx, ok := as.confirmedMissingReceiptTxs[txID]
if !ok || tx == nil {
return fmt.Errorf("move_confirmed_missing_receipt_to_fatal_error: no confirmed_missing_receipt transaction with ID %d", txID)
}

tx.State = TxFatalError
tx.Sequence = nil
tx.TxAttempts = nil
tx.InitialBroadcastAt = nil
tx.Error = txError
as.fatalErroredTxs[tx.ID] = tx
delete(as.confirmedMissingReceiptTxs, tx.ID)

return nil
}

Expand Down

0 comments on commit 1aa98d3

Please sign in to comment.