From c257fffd9bad03474674ef9e70e85fae6757bb2d Mon Sep 17 00:00:00 2001 From: Aditya Vyas Date: Tue, 12 Sep 2023 12:56:11 -0400 Subject: [PATCH] Remove sequenceNumber from checkTxAlreadyExists --- services/horizon/internal/txsub/results.go | 14 +++++++------- services/horizon/internal/txsub/system.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/horizon/internal/txsub/results.go b/services/horizon/internal/txsub/results.go index e9d91bc35e..d85448fd89 100644 --- a/services/horizon/internal/txsub/results.go +++ b/services/horizon/internal/txsub/results.go @@ -55,13 +55,13 @@ func txResultFromHistory(tx history.Transaction) (history.Transaction, error) { // queries execute on different ledgers. In this case, txsub can mistakenly respond with a bad_seq error // because the first query occurs when the tx is not yet ingested and the second query occurs when the tx // is ingested. -func checkTxAlreadyExists(ctx context.Context, db HorizonDB, hash, sourceAddress string) (history.Transaction, uint64, error) { +func checkTxAlreadyExists(ctx context.Context, db HorizonDB, hash, sourceAddress string) (history.Transaction, error) { err := db.BeginTx(ctx, &sql.TxOptions{ Isolation: sql.LevelRepeatableRead, ReadOnly: true, }) if err != nil { - return history.Transaction{}, 0, errors.Wrap(err, "cannot start repeatable read tx") + return history.Transaction{}, errors.Wrap(err, "cannot start repeatable read tx") } defer db.Rollback() @@ -70,14 +70,14 @@ func checkTxAlreadyExists(ctx context.Context, db HorizonDB, hash, sourceAddress var sequenceNumbers map[string]uint64 sequenceNumbers, err = db.GetSequenceNumbers(ctx, []string{sourceAddress}) if err != nil { - return tx, 0, errors.Wrapf(err, "cannot fetch sequence number for %v", sourceAddress) + return tx, errors.Wrapf(err, "cannot fetch sequence number for %v", sourceAddress) } - num, ok := sequenceNumbers[sourceAddress] + _, ok := sequenceNumbers[sourceAddress] if !ok { - return tx, 0, ErrNoAccount + return tx, ErrNoAccount } - return tx, num, ErrNoResults + return tx, ErrNoResults } - return tx, 0, err + return tx, err } diff --git a/services/horizon/internal/txsub/system.go b/services/horizon/internal/txsub/system.go index 9227b5f895..2e61eeafc7 100644 --- a/services/horizon/internal/txsub/system.go +++ b/services/horizon/internal/txsub/system.go @@ -120,7 +120,7 @@ func (sys *System) Submit( return } - tx, _, err := checkTxAlreadyExists(ctx, db, hash, sourceAddress) + tx, err := checkTxAlreadyExists(ctx, db, hash, sourceAddress) if err == nil { sys.Log.Ctx(ctx).WithField("hash", hash).Info("Found submission result in a DB") sys.finish(ctx, hash, resultCh, Result{Transaction: tx})