Skip to content

Commit

Permalink
handle reorg after confirm cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Farber98 committed Nov 30, 2024
1 parent f4c6069 commit f027aeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions pkg/solana/txm/pendingtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,14 @@ func (c *pendingTxContext) OnProcessed(sig solana.Signature) (string, error) {
if !sigExists {
return info.id, ErrSigDoesNotExist
}
tx, exists := c.broadcastedProcessedTxs[info.id]
_, exists := c.broadcastedProcessedTxs[info.id]
if !exists {
return info.id, ErrTransactionNotFound
}
// update sig to Processed
info.state = Processed
// save updated sig and tx back to the maps
c.sigToTxInfo[sig] = info
c.broadcastedProcessedTxs[info.id] = tx
return info.id, nil
})
}
Expand Down
14 changes: 5 additions & 9 deletions pkg/solana/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,27 +465,23 @@ func (txm *Txm) processConfirmations(ctx context.Context, client client.ReaderWr
continue
}

// check if a potential re-org has occurred for this sig and handle it
err := txm.handleReorg(ctx, sig, status)
if err != nil {
continue
}

switch status.ConfirmationStatus {
case rpc.ConfirmationStatusProcessed:
// if signature is processed, keep polling for confirmed or finalized status
txm.handleProcessedSignatureStatus(sig)
continue
case rpc.ConfirmationStatusConfirmed:
// if signature is confirmed, keep polling for finalized status
txm.handleConfirmedSignatureStatus(sig)
continue
case rpc.ConfirmationStatusFinalized:
// if signature is finalized, end polling
txm.handleFinalizedSignatureStatus(sig)
continue
default:
txm.lggr.Warnw("unknown confirmation status", "signature", sig, "status", status.ConfirmationStatus)
}

// check if a potential re-org has occurred for this sig and handle it
err := txm.handleReorg(ctx, sig, status)
if err != nil {
continue
}
}
Expand Down

0 comments on commit f027aeb

Please sign in to comment.