Skip to content

Commit

Permalink
fix save replacement in progress attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
poopoothegorilla committed Jan 19, 2024
1 parent da1df83 commit ba5ef07
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions common/txmgr/inmemory_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,22 @@ func (ms *InMemoryStore[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) SaveR
return fmt.Errorf("save_replacement_in_progress_attempt: %w", err)
}

// Update in memory store
tx, err := as.PeekInProgressTx()
if tx == nil {
return fmt.Errorf("save_replacement_in_progress_attempt: %w", err)
}
// TODO: DOES THIS ATTEMPT HAVE AN ID? IF NOT, HOW DO WE GET IT?
tx.TxAttempts = []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]{*replacementAttempt}

var found bool
for i := 0; i < len(tx.TxAttempts); i++ {
if tx.TxAttempts[i].ID == oldAttempt.ID {
tx.TxAttempts[i] = *replacementAttempt
found = true
}
}
if !found {
tx.TxAttempts = append(tx.TxAttempts, *replacementAttempt)
}

return nil
}
Expand Down

0 comments on commit ba5ef07

Please sign in to comment.