Skip to content

Commit

Permalink
Fix/rfq status (#2261)
Browse files Browse the repository at this point in the history
* [goreleaser]

* do not flatten [goreleaser]

* [goreleaser]

* lint fix

---------

Co-authored-by: Trajan0x <[email protected]>
  • Loading branch information
trajan0x and trajan0x authored Mar 13, 2024
1 parent 767853c commit af3118d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions services/rfq/relayer/reldb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func (q QuoteRequest) GetDestIDPair() string {
//
// TODO: consider making this an interface and exporting that.
//
// EXTREMELY IMPORTANT: DO NOT ADD NEW VALUES TO THIS ENUM UNLESS THEY ARE AT THE END.
//
//go:generate go run golang.org/x/tools/cmd/stringer -type=QuoteRequestStatus
type QuoteRequestStatus uint8

Expand Down Expand Up @@ -123,6 +125,8 @@ const (
ClaimPending
// ClaimCompleted means the relayer has called Claim() on the origin chain, and the tx has been confirmed on chain.
ClaimCompleted
// RelayRaceLost means another relayer has relayed the tx.
RelayRaceLost
)

// Int returns the int value of the quote request status.
Expand Down
5 changes: 3 additions & 2 deletions services/rfq/relayer/reldb/quoterequeststatus_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions services/rfq/relayer/service/chainindexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ func (r *Relayer) runChainIndexer(ctx context.Context, chainID int) (err error)
case *fastbridge.FastBridgeBridgeRelayed:
// it wasn't me
if event.Relayer != r.signer.Address() {
return nil
//nolint: wrapcheck
return r.db.UpdateQuoteRequestStatus(ctx, event.TransactionId, reldb.RelayRaceLost)
}

err = r.handleRelayLog(ctx, event)
Expand All @@ -88,7 +89,8 @@ func (r *Relayer) runChainIndexer(ctx context.Context, chainID int) (err error)
case *fastbridge.FastBridgeBridgeProofProvided:
// it wasn't me
if event.Relayer != r.signer.Address() {
return nil
//nolint: wrapcheck
return r.db.UpdateQuoteRequestStatus(ctx, event.TransactionId, reldb.RelayRaceLost)
}

err = r.handleProofProvided(ctx, event)
Expand All @@ -98,7 +100,8 @@ func (r *Relayer) runChainIndexer(ctx context.Context, chainID int) (err error)
case *fastbridge.FastBridgeBridgeDepositClaimed:
// it wasn't me
if event.Relayer != r.signer.Address() {
return nil
//nolint: wrapcheck
return r.db.UpdateQuoteRequestStatus(ctx, event.TransactionId, reldb.RelayRaceLost)
}

err = r.handleDepositClaimed(ctx, event, chainID)
Expand Down

0 comments on commit af3118d

Please sign in to comment.