Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/handler/frontend_move.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ func (h *FrontendMoveHandler) monitorTransactionStatus(recordID int64, txHash st
log.Infof("[FrontendMoveHandler] Transaction %s status updated to %s", txHash, status)

// If transaction is successful, mark related records
if receipt.Status == 1 {
h.markRelatedRecords(txHash, receipt.BlockNumber.Int64())
}
// if receipt.Status == 1 {
// h.markRelatedRecords(txHash, receipt.BlockNumber.Int64())
// }

return
}
Expand All @@ -159,7 +159,7 @@ func (h *FrontendMoveHandler) monitorTransactionStatus(recordID int64, txHash st
log.Warnf("[FrontendMoveHandler] Transaction %s monitoring timeout", txHash)
}

// markRelatedRecords marks related block and event records
//nolint:unused
func (h *FrontendMoveHandler) markRelatedRecords(txHash string, blockNumber int64) {
// Mark related blocks
err := h.svc.DB.Model(&schema.DisputeGame{}).
Expand Down
26 changes: 18 additions & 8 deletions internal/handler/syncFrontendMove.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package handler

import (
"fmt"
"time"

"github.com/optimism-java/dispute-explorer/internal/schema"
Expand Down Expand Up @@ -43,10 +44,12 @@ func processFrontendMoveTransactions(ctx *svc.ServiceContext) error {

for i := range unsyncedTransactions {
transaction := &unsyncedTransactions[i]
err := syncSingleTransaction(ctx, transaction)
if err != nil {
log.Errorf("[Handler.SyncFrontendMoveTransactions] Failed to sync transaction %s: %s", transaction.TxHash, err)
continue
if transaction.Status == schema.FrontendMoveStatusConfirmed {
err := syncSingleTransaction(ctx, transaction)
if err != nil {
log.Errorf("[Handler.SyncFrontendMoveTransactions] Failed to sync transaction %s: %s", transaction.TxHash, err)
continue
}
}
}

Expand All @@ -72,12 +75,19 @@ func syncSingleTransaction(ctx *svc.ServiceContext, transaction *schema.Frontend
}

// 2. update game_claim_data is_from_frontend column to true
err = tx.Model(&schema.GameClaimData{}).
result := tx.Model(&schema.GameClaimData{}).
Where("game_contract = ? AND parent_index = ?", transaction.GameContract, transaction.ParentIndex).
Update("is_from_frontend", true).Error
if err != nil {
Update("is_from_frontend", true)
if result.Error != nil {
tx.Rollback()
return err
return result.Error
}

if result.RowsAffected == 0 {
tx.Rollback()
log.Warnf("[Handler.SyncFrontendMoveTransactions] No matching game_claim_data found for transaction %s (game: %s, parent_index: %s), will retry later",
transaction.TxHash, transaction.GameContract, transaction.ParentIndex)
return fmt.Errorf("no matching game_claim_data found, will retry later")
}

// 3. update frontend_move_transactions is_synced column to true
Expand Down
Loading