Skip to content

Commit

Permalink
fix keeper mtg transaction outputs invalid trace id
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricfung committed Oct 28, 2024
1 parent e8334ca commit 55503e7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cmd/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ func mtgFixCache(ctx context.Context, path string) {
}
defer txn.Rollback()

row := txn.QueryRowContext(ctx, "SELECT trace_id,app_id,opponent_app_id,state,asset_id,receivers,threshold,amount,refs,sequence,compaction,storage FROM transactions WHERE trace_id=?", "24a1cdf1-872d-3cc2-b826-e2a888b67303")
var traceId, appId, opponentAppId, assetId, receivers, amount, refs string
row := txn.QueryRowContext(ctx, "SELECT trace_id,app_id,opponent_app_id,state,asset_id,receivers,threshold,amount,refs,sequence,compaction,storage,storage_trace_id FROM transactions WHERE trace_id=?", "24a1cdf1-872d-3cc2-b826-e2a888b67303")
var traceId, appId, opponentAppId, assetId, receivers, amount, refs, storageTraceId string
var state, threshold, sequence int64
var compaction, storage bool
err = row.Scan(&traceId, &appId, &opponentAppId, &state, &assetId, &receivers, &threshold, &amount, &refs, &sequence, &compaction, &storage)
err = row.Scan(&traceId, &appId, &opponentAppId, &state, &assetId, &receivers, &threshold, &amount, &refs, &sequence, &compaction, &storage, &storageTraceId)
if err == sql.ErrNoRows {
return
} else if err != nil {
Expand All @@ -55,7 +55,16 @@ func mtgFixCache(ctx context.Context, path string) {
panic(err)
}

r, err = txn.ExecContext(ctx, "INSERT INTO transactions (trace_id,app_id,opponent_app_id,state,asset_id,receivers,threshold,amount,refs,sequence,compaction,storage,memo) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", "239f25cd-ee77-3534-b3dd-1c1815b581b6", appId, opponentAppId, state, assetId, receivers, threshold, amount, refs, sequence, compaction, storage, string(memo))
r, err = txn.ExecContext(ctx, "INSERT INTO transactions (trace_id,app_id,opponent_app_id,state,asset_id,receivers,threshold,amount,refs,sequence,compaction,storage,memo,updated_at,storage_trace_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", "239f25cd-ee77-3534-b3dd-1c1815b581b6", appId, opponentAppId, state, assetId, receivers, threshold, amount, refs, sequence, compaction, storage, string(memo), time.Time{}, storageTraceId)
if err != nil {
panic(err)
}
rac, err = r.RowsAffected()
if err != nil || rac != 1 {
panic(err)
}

r, err = txn.ExecContext(ctx, "UPDATE outputs SET trace_id='239f25cd-ee77-3534-b3dd-1c1815b581b6' WHERE trace_id='24a1cdf1-872d-3cc2-b826-e2a888b67303'")
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 55503e7

Please sign in to comment.