Remove the need to pass a transaction when upserting to known_gaps
Thanks Ian :D
This commit is contained in:
parent
bca12f9cdf
commit
73f46a59ef
@ -562,18 +562,8 @@ func (sdi *StateDiffIndexer) PushKnownGaps(startingBlockNumber *big.Int, endingB
|
||||
CheckedOut: checkedOut,
|
||||
ProcessingKey: processingKey,
|
||||
}
|
||||
tx, err := sdi.dbWriter.db.Begin(sdi.ctx)
|
||||
if err != nil {
|
||||
if err := sdi.dbWriter.upsertKnownGaps(knownGap); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := sdi.dbWriter.upsertKnownGaps(tx, knownGap); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tx.Commit(sdi.ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package sql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@ -183,14 +184,12 @@ func (w *Writer) upsertStorageCID(tx Tx, storageCID models.StorageNodeModel) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *Writer) upsertKnownGaps(tx Tx, knownGaps models.KnownGapsModel) error {
|
||||
res, err := tx.Exec(w.db.Context(), w.db.InsertKnownGapsStm(),
|
||||
func (w *Writer) upsertKnownGaps(knownGaps models.KnownGapsModel) error {
|
||||
_, err := w.db.Exec(context.Background(), w.db.InsertKnownGapsStm(),
|
||||
knownGaps.StartingBlockNumber, knownGaps.EndingBlockNumber, knownGaps.CheckedOut, knownGaps.ProcessingKey)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error upserting known_gaps entry: %v", err)
|
||||
}
|
||||
|
||||
ret, _ := res.RowsAffected()
|
||||
fmt.Println("Res:", ret)
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user