From 1aa98d389f15be93da78c45481e956b025eeea1b Mon Sep 17 00:00:00 2001 From: James Walker Date: Fri, 23 Feb 2024 16:39:33 -0500 Subject: [PATCH] implement MoveConfirmedMissingReceiptToFatalError --- common/txmgr/address_state.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/common/txmgr/address_state.go b/common/txmgr/address_state.go index 1c0a4d2d747..99b6b9d9f79 100644 --- a/common/txmgr/address_state.go +++ b/common/txmgr/address_state.go @@ -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 }