diff --git a/cmd/backfillMakerLogs.go b/cmd/backfillMakerLogs.go index 4f19038e..33b9e919 100644 --- a/cmd/backfillMakerLogs.go +++ b/cmd/backfillMakerLogs.go @@ -17,8 +17,6 @@ package cmd import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - shared2 "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/libraries/shared" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/transformers" @@ -47,9 +45,7 @@ func backfillMakerLogs() { log.Fatal("Failed to initialize database.") } - repository := &shared2.Repository{} - fetcher := shared2.NewFetcher(blockChain) - watcher := shared.NewWatcher(db, fetcher, repository) + watcher := shared.NewWatcher(db, blockChain) watcher.AddTransformers(transformers.TransformerInitializers()) err = watcher.Execute() diff --git a/cmd/continuousLogSync.go b/cmd/continuousLogSync.go index f6824e2e..710a6bf4 100644 --- a/cmd/continuousLogSync.go +++ b/cmd/continuousLogSync.go @@ -58,12 +58,9 @@ func syncMakerLogs() { log.Fatal("Failed to initialize database.") } - fetcher := shared2.NewFetcher(blockChain) - repository := &shared2.Repository{} - initializers := getTransformerInitializers(transformerNames) - watcher := shared.NewWatcher(db, fetcher, repository) + watcher := shared.NewWatcher(db, blockChain) watcher.AddTransformers(initializers) for range ticker.C { diff --git a/environments/staging.toml b/environments/staging.toml index 6ed252dd..bcdf0079 100644 --- a/environments/staging.toml +++ b/environments/staging.toml @@ -6,7 +6,7 @@ password = "vulcanize" port = 5432 [client] -ipcPath = "http://147.75.199.135:8545" +ipcPath = "http://kovan0.vulcanize.io:8545" [datadog] name = "maker_vdb_staging" diff --git a/libraries/shared/watcher.go b/libraries/shared/watcher.go index 7b68752c..8a8ded13 100644 --- a/libraries/shared/watcher.go +++ b/libraries/shared/watcher.go @@ -8,12 +8,6 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" ) -type WatcherRepository interface { - GetCheckedColumnNames(db *postgres.DB) ([]string, error) - CreateNotCheckedSQL(boolColumns []string) string - MissingHeaders(startingBlockNumber int64, endingBlockNumber int64, db *postgres.DB, notCheckedSQL string) ([]core.Header, error) -} - type Watcher struct { Transformers []shared.Transformer DB *postgres.DB @@ -21,16 +15,15 @@ type Watcher struct { Chunker shared.Chunker Addresses []common.Address Topics []common.Hash - Repository WatcherRepository } -func NewWatcher(db *postgres.DB, fetcher shared.LogFetcher, repository WatcherRepository) Watcher { +func NewWatcher(db *postgres.DB, bc core.BlockChain) Watcher { chunker := shared.NewLogChunker() + fetcher := shared.NewFetcher(bc) return Watcher{ - DB: db, - Fetcher: fetcher, - Chunker: chunker, - Repository: repository, + DB: db, + Fetcher: fetcher, + Chunker: chunker, } } @@ -58,14 +51,14 @@ func (watcher *Watcher) AddTransformers(initializers []shared.TransformerInitial } func (watcher *Watcher) Execute() error { - checkedColumnNames, err := watcher.Repository.GetCheckedColumnNames(watcher.DB) + checkedColumnNames, err := shared.GetCheckedColumnNames(watcher.DB) if err != nil { return err } - notCheckedSQL := watcher.Repository.CreateNotCheckedSQL(checkedColumnNames) + notCheckedSQL := shared.CreateNotCheckedSQL(checkedColumnNames) // TODO Handle start and end numbers in transformers - missingHeaders, err := watcher.Repository.MissingHeaders(0, -1, watcher.DB, notCheckedSQL) + missingHeaders, err := shared.MissingHeaders(0, -1, watcher.DB, notCheckedSQL) if err != nil { log.Error("Fetching of missing headers failed in watcher!") return err diff --git a/pkg/transformers/bite/repository.go b/pkg/transformers/bite/repository.go index 290deaee..1e3d860b 100644 --- a/pkg/transformers/bite/repository.go +++ b/pkg/transformers/bite/repository.go @@ -52,7 +52,7 @@ func (repository BiteRepository) Create(headerID int64, models []interface{}) er } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.BiteChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.BiteChecked) if err != nil { tx.Rollback() return err @@ -62,5 +62,5 @@ func (repository BiteRepository) Create(headerID int64, models []interface{}) er } func (repository BiteRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.BiteChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.BiteChecked) } diff --git a/pkg/transformers/cat_file/chop_lump/repository.go b/pkg/transformers/cat_file/chop_lump/repository.go index c63e83b6..9dff41f7 100644 --- a/pkg/transformers/cat_file/chop_lump/repository.go +++ b/pkg/transformers/cat_file/chop_lump/repository.go @@ -49,7 +49,7 @@ func (repository CatFileChopLumpRepository) Create(headerID int64, models []inte } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFileChopLumpChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFileChopLumpChecked) if err != nil { tx.Rollback() return err @@ -58,7 +58,7 @@ func (repository CatFileChopLumpRepository) Create(headerID int64, models []inte } func (repository CatFileChopLumpRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.CatFileChopLumpChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.CatFileChopLumpChecked) } func (repository *CatFileChopLumpRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/cat_file/flip/repository.go b/pkg/transformers/cat_file/flip/repository.go index 624e37d3..a07ca207 100644 --- a/pkg/transformers/cat_file/flip/repository.go +++ b/pkg/transformers/cat_file/flip/repository.go @@ -48,7 +48,7 @@ func (repository CatFileFlipRepository) Create(headerID int64, models []interfac } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFileFlipChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFileFlipChecked) if err != nil { tx.Rollback() return err @@ -57,7 +57,7 @@ func (repository CatFileFlipRepository) Create(headerID int64, models []interfac } func (repository CatFileFlipRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.CatFileFlipChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.CatFileFlipChecked) } func (repository *CatFileFlipRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/cat_file/pit_vow/repository.go b/pkg/transformers/cat_file/pit_vow/repository.go index 8e2e3a29..861dc2a8 100644 --- a/pkg/transformers/cat_file/pit_vow/repository.go +++ b/pkg/transformers/cat_file/pit_vow/repository.go @@ -48,7 +48,7 @@ func (repository CatFilePitVowRepository) Create(headerID int64, models []interf } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFilePitVowChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFilePitVowChecked) if err != nil { tx.Rollback() return err @@ -57,7 +57,7 @@ func (repository CatFilePitVowRepository) Create(headerID int64, models []interf } func (repository CatFilePitVowRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.CatFilePitVowChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.CatFilePitVowChecked) } func (repository *CatFilePitVowRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/deal/repository.go b/pkg/transformers/deal/repository.go index 825f00d6..06f23230 100644 --- a/pkg/transformers/deal/repository.go +++ b/pkg/transformers/deal/repository.go @@ -49,7 +49,7 @@ func (repository DealRepository) Create(headerID int64, models []interface{}) er } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DealChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DealChecked) if err != nil { tx.Rollback() return err @@ -58,7 +58,7 @@ func (repository DealRepository) Create(headerID int64, models []interface{}) er } func (repository DealRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DealChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.DealChecked) } func (repository *DealRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/dent/repository.go b/pkg/transformers/dent/repository.go index 80aee3e0..0ff5370b 100644 --- a/pkg/transformers/dent/repository.go +++ b/pkg/transformers/dent/repository.go @@ -54,7 +54,7 @@ func (repository DentRepository) Create(headerID int64, models []interface{}) er } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DentChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DentChecked) if err != nil { tx.Rollback() return err @@ -63,7 +63,7 @@ func (repository DentRepository) Create(headerID int64, models []interface{}) er } func (repository DentRepository) MarkHeaderChecked(headerId int64) error { - return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.DentChecked) + return shared.MarkHeaderChecked(headerId, repository.db, constants.DentChecked) } func (repository *DentRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/drip_drip/repository.go b/pkg/transformers/drip_drip/repository.go index c9fa1623..edb1208a 100644 --- a/pkg/transformers/drip_drip/repository.go +++ b/pkg/transformers/drip_drip/repository.go @@ -48,7 +48,7 @@ func (repository DripDripRepository) Create(headerID int64, models []interface{} } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripDripChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripDripChecked) if err != nil { tx.Rollback() return err @@ -57,7 +57,7 @@ func (repository DripDripRepository) Create(headerID int64, models []interface{} } func (repository DripDripRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DripDripChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.DripDripChecked) } func (repository *DripDripRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/drip_file/ilk/repository.go b/pkg/transformers/drip_file/ilk/repository.go index 3740c548..117a28fd 100644 --- a/pkg/transformers/drip_file/ilk/repository.go +++ b/pkg/transformers/drip_file/ilk/repository.go @@ -50,7 +50,7 @@ func (repository DripFileIlkRepository) Create(headerID int64, models []interfac } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileIlkChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileIlkChecked) if err != nil { tx.Rollback() return err @@ -60,7 +60,7 @@ func (repository DripFileIlkRepository) Create(headerID int64, models []interfac } func (repository DripFileIlkRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DripFileIlkChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.DripFileIlkChecked) } func (repository *DripFileIlkRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/drip_file/repo/repository.go b/pkg/transformers/drip_file/repo/repository.go index 23d08af2..dc9589a7 100644 --- a/pkg/transformers/drip_file/repo/repository.go +++ b/pkg/transformers/drip_file/repo/repository.go @@ -50,7 +50,7 @@ func (repository DripFileRepoRepository) Create(headerID int64, models []interfa } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileRepoChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileRepoChecked) if err != nil { tx.Rollback() return err @@ -60,7 +60,7 @@ func (repository DripFileRepoRepository) Create(headerID int64, models []interfa } func (repository DripFileRepoRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DripFileRepoChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.DripFileRepoChecked) } func (repository *DripFileRepoRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/drip_file/vow/repository.go b/pkg/transformers/drip_file/vow/repository.go index 86bdf8f2..aa23bea8 100644 --- a/pkg/transformers/drip_file/vow/repository.go +++ b/pkg/transformers/drip_file/vow/repository.go @@ -49,7 +49,7 @@ func (repository DripFileVowRepository) Create(headerID int64, models []interfac } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileVowChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileVowChecked) if err != nil { tx.Rollback() return err @@ -59,7 +59,7 @@ func (repository DripFileVowRepository) Create(headerID int64, models []interfac } func (repository DripFileVowRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DripFileVowChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.DripFileVowChecked) } func (repository *DripFileVowRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/flap_kick/repository.go b/pkg/transformers/flap_kick/repository.go index 950ebcb0..f9f11c7a 100644 --- a/pkg/transformers/flap_kick/repository.go +++ b/pkg/transformers/flap_kick/repository.go @@ -47,7 +47,7 @@ func (repository *FlapKickRepository) Create(headerID int64, models []interface{ } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlapKickChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlapKickChecked) if err != nil { tx.Rollback() return err @@ -56,7 +56,7 @@ func (repository *FlapKickRepository) Create(headerID int64, models []interface{ } func (repository *FlapKickRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.FlapKickChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.FlapKickChecked) } func (repository *FlapKickRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/flip_kick/repository.go b/pkg/transformers/flip_kick/repository.go index 99c376be..db8a8d01 100644 --- a/pkg/transformers/flip_kick/repository.go +++ b/pkg/transformers/flip_kick/repository.go @@ -47,7 +47,7 @@ func (repository FlipKickRepository) Create(headerID int64, models []interface{} return err } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlipKickChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlipKickChecked) if err != nil { tx.Rollback() return err @@ -56,7 +56,7 @@ func (repository FlipKickRepository) Create(headerID int64, models []interface{} } func (repository FlipKickRepository) MarkHeaderChecked(headerId int64) error { - return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.FlipKickChecked) + return shared.MarkHeaderChecked(headerId, repository.db, constants.FlipKickChecked) } func (repository *FlipKickRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/flop_kick/repository.go b/pkg/transformers/flop_kick/repository.go index 1bab62c6..7a302c75 100644 --- a/pkg/transformers/flop_kick/repository.go +++ b/pkg/transformers/flop_kick/repository.go @@ -48,7 +48,7 @@ func (repository FlopKickRepository) Create(headerID int64, models []interface{} } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlopKickChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlopKickChecked) if err != nil { tx.Rollback() return err @@ -58,7 +58,7 @@ func (repository FlopKickRepository) Create(headerID int64, models []interface{} } func (repository FlopKickRepository) MarkHeaderChecked(headerId int64) error { - return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.FlopKickChecked) + return shared.MarkHeaderChecked(headerId, repository.db, constants.FlopKickChecked) } func (repository *FlopKickRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/frob/repository.go b/pkg/transformers/frob/repository.go index e2c26435..bf6d4d08 100644 --- a/pkg/transformers/frob/repository.go +++ b/pkg/transformers/frob/repository.go @@ -46,7 +46,7 @@ func (repository FrobRepository) Create(headerID int64, models []interface{}) er return err } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.FrobChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FrobChecked) if err != nil { tx.Rollback() return err @@ -55,7 +55,7 @@ func (repository FrobRepository) Create(headerID int64, models []interface{}) er } func (repository FrobRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.FrobChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.FrobChecked) } func (repository *FrobRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/pit_file/debt_ceiling/repository.go b/pkg/transformers/pit_file/debt_ceiling/repository.go index 38b648ba..12f69fb2 100644 --- a/pkg/transformers/pit_file/debt_ceiling/repository.go +++ b/pkg/transformers/pit_file/debt_ceiling/repository.go @@ -50,7 +50,7 @@ func (repository PitFileDebtCeilingRepository) Create(headerID int64, models []i } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.PitFileDebtCeilingChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.PitFileDebtCeilingChecked) if err != nil { tx.Rollback() return err @@ -60,7 +60,7 @@ func (repository PitFileDebtCeilingRepository) Create(headerID int64, models []i } func (repository PitFileDebtCeilingRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.PitFileDebtCeilingChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.PitFileDebtCeilingChecked) } func (repository *PitFileDebtCeilingRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/pit_file/ilk/repository.go b/pkg/transformers/pit_file/ilk/repository.go index 3dae51c6..9a187de7 100644 --- a/pkg/transformers/pit_file/ilk/repository.go +++ b/pkg/transformers/pit_file/ilk/repository.go @@ -49,7 +49,7 @@ func (repository PitFileIlkRepository) Create(headerID int64, models []interface } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.PitFileIlkChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.PitFileIlkChecked) if err != nil { tx.Rollback() return err @@ -58,7 +58,7 @@ func (repository PitFileIlkRepository) Create(headerID int64, models []interface } func (repository PitFileIlkRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.PitFileIlkChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.PitFileIlkChecked) } func (repository *PitFileIlkRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/price_feeds/repository.go b/pkg/transformers/price_feeds/repository.go index af1caf19..cbb9a012 100644 --- a/pkg/transformers/price_feeds/repository.go +++ b/pkg/transformers/price_feeds/repository.go @@ -45,7 +45,7 @@ func (repository PriceFeedRepository) Create(headerID int64, models []interface{ } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.PriceFeedsChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.PriceFeedsChecked) if err != nil { tx.Rollback() return err @@ -54,7 +54,7 @@ func (repository PriceFeedRepository) Create(headerID int64, models []interface{ } func (repository PriceFeedRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.PriceFeedsChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.PriceFeedsChecked) } func (repository *PriceFeedRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/shared/repository.go b/pkg/transformers/shared/repository.go index 933b999d..65c01c99 100644 --- a/pkg/transformers/shared/repository.go +++ b/pkg/transformers/shared/repository.go @@ -9,9 +9,7 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" ) -type Repository struct{} - -func (_ Repository) MarkHeaderChecked(headerID int64, db *postgres.DB, checkedHeadersColumn string) error { +func MarkHeaderChecked(headerID int64, db *postgres.DB, checkedHeadersColumn string) error { _, err := db.Exec(`INSERT INTO public.checked_headers (header_id, `+checkedHeadersColumn+`) VALUES ($1, $2) ON CONFLICT (header_id) DO @@ -19,7 +17,7 @@ func (_ Repository) MarkHeaderChecked(headerID int64, db *postgres.DB, checkedHe return err } -func (_ Repository) MarkHeaderCheckedInTransaction(headerID int64, tx *sql.Tx, checkedHeadersColumn string) error { +func MarkHeaderCheckedInTransaction(headerID int64, tx *sql.Tx, checkedHeadersColumn string) error { _, err := tx.Exec(`INSERT INTO public.checked_headers (header_id, `+checkedHeadersColumn+`) VALUES ($1, $2) ON CONFLICT (header_id) DO @@ -28,7 +26,7 @@ func (_ Repository) MarkHeaderCheckedInTransaction(headerID int64, tx *sql.Tx, c } // Treats a header as missing if it's not in the headers table, or not checked for some log type -func (_ Repository) MissingHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.DB, notCheckedSQL string) ([]core.Header, error) { +func MissingHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.DB, notCheckedSQL string) ([]core.Header, error) { var result []core.Header var query string var err error @@ -53,7 +51,7 @@ func (_ Repository) MissingHeaders(startingBlockNumber, endingBlockNumber int64, return result, err } -func (_ Repository) GetCheckedColumnNames(db *postgres.DB) ([]string, error) { +func GetCheckedColumnNames(db *postgres.DB) ([]string, error) { // Query returns `[]driver.Value`, nullable polymorphic interface var queryResult []driver.Value columnNamesQuery := @@ -84,7 +82,7 @@ func (_ Repository) GetCheckedColumnNames(db *postgres.DB) ([]string, error) { // Defaults to FALSE when no columns are provided. // Ex: ["columnA", "columnB"] => "NOT (columnA AND columnB)" // [] => "FALSE" -func (_ Repository) CreateNotCheckedSQL(boolColumns []string) string { +func CreateNotCheckedSQL(boolColumns []string) string { var result bytes.Buffer if len(boolColumns) == 0 { diff --git a/pkg/transformers/tend/repository.go b/pkg/transformers/tend/repository.go index bfabd248..17620a00 100644 --- a/pkg/transformers/tend/repository.go +++ b/pkg/transformers/tend/repository.go @@ -55,7 +55,7 @@ func (repository TendRepository) Create(headerID int64, models []interface{}) er } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.TendChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.TendChecked) if err != nil { tx.Rollback() return err @@ -64,7 +64,7 @@ func (repository TendRepository) Create(headerID int64, models []interface{}) er } func (repository TendRepository) MarkHeaderChecked(headerId int64) error { - return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.TendChecked) + return shared.MarkHeaderChecked(headerId, repository.db, constants.TendChecked) } func (repository *TendRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/vat_flux/repository.go b/pkg/transformers/vat_flux/repository.go index 78089701..2febe527 100644 --- a/pkg/transformers/vat_flux/repository.go +++ b/pkg/transformers/vat_flux/repository.go @@ -47,7 +47,7 @@ func (repository VatFluxRepository) Create(headerID int64, models []interface{}) } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatFluxChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatFluxChecked) if err != nil { tx.Rollback() return err @@ -57,7 +57,7 @@ func (repository VatFluxRepository) Create(headerID int64, models []interface{}) } func (repository VatFluxRepository) MarkHeaderChecked(headerId int64) error { - return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.VatFluxChecked) + return shared.MarkHeaderChecked(headerId, repository.db, constants.VatFluxChecked) } func (repository *VatFluxRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/vat_fold/repository.go b/pkg/transformers/vat_fold/repository.go index 01ba28ba..5d831bca 100644 --- a/pkg/transformers/vat_fold/repository.go +++ b/pkg/transformers/vat_fold/repository.go @@ -49,7 +49,7 @@ func (repository VatFoldRepository) Create(headerID int64, models []interface{}) } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatFoldChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatFoldChecked) if err != nil { tx.Rollback() return err @@ -59,7 +59,7 @@ func (repository VatFoldRepository) Create(headerID int64, models []interface{}) } func (repository VatFoldRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatFoldChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.VatFoldChecked) } func (repository *VatFoldRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/vat_grab/repository.go b/pkg/transformers/vat_grab/repository.go index 14364b90..a8a274a4 100644 --- a/pkg/transformers/vat_grab/repository.go +++ b/pkg/transformers/vat_grab/repository.go @@ -34,7 +34,7 @@ func (repository VatGrabRepository) Create(headerID int64, models []interface{}) return err } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatGrabChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatGrabChecked) if err != nil { tx.Rollback() return err @@ -43,7 +43,7 @@ func (repository VatGrabRepository) Create(headerID int64, models []interface{}) } func (repository VatGrabRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatGrabChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.VatGrabChecked) } func (repository *VatGrabRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/vat_heal/repository.go b/pkg/transformers/vat_heal/repository.go index 861025a6..aed8fcd0 100644 --- a/pkg/transformers/vat_heal/repository.go +++ b/pkg/transformers/vat_heal/repository.go @@ -52,7 +52,7 @@ func (repository VatHealRepository) Create(headerID int64, models []interface{}) } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatHealChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatHealChecked) if err != nil { tx.Rollback() return err @@ -61,5 +61,5 @@ func (repository VatHealRepository) Create(headerID int64, models []interface{}) } func (repository VatHealRepository) MarkHeaderChecked(headerId int64) error { - return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.VatHealChecked) + return shared.MarkHeaderChecked(headerId, repository.db, constants.VatHealChecked) } diff --git a/pkg/transformers/vat_init/repository.go b/pkg/transformers/vat_init/repository.go index 1bb56d12..14b2d4c8 100644 --- a/pkg/transformers/vat_init/repository.go +++ b/pkg/transformers/vat_init/repository.go @@ -49,7 +49,7 @@ func (repository VatInitRepository) Create(headerID int64, models []interface{}) } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatInitChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatInitChecked) if err != nil { tx.Rollback() return err @@ -59,7 +59,7 @@ func (repository VatInitRepository) Create(headerID int64, models []interface{}) } func (repository VatInitRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatInitChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.VatInitChecked) } func (repository *VatInitRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/vat_move/repository.go b/pkg/transformers/vat_move/repository.go index 913b587c..2548c2b4 100644 --- a/pkg/transformers/vat_move/repository.go +++ b/pkg/transformers/vat_move/repository.go @@ -50,7 +50,7 @@ func (repository VatMoveRepository) Create(headerID int64, models []interface{}) } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatMoveChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatMoveChecked) if err != nil { tx.Rollback() return err @@ -60,7 +60,7 @@ func (repository VatMoveRepository) Create(headerID int64, models []interface{}) } func (repository VatMoveRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatMoveChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.VatMoveChecked) } func (repository *VatMoveRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/vat_slip/repository.go b/pkg/transformers/vat_slip/repository.go index b84f248c..15f412ca 100644 --- a/pkg/transformers/vat_slip/repository.go +++ b/pkg/transformers/vat_slip/repository.go @@ -34,7 +34,7 @@ func (repository VatSlipRepository) Create(headerID int64, models []interface{}) } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatSlipChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatSlipChecked) if err != nil { tx.Rollback() return err @@ -44,7 +44,7 @@ func (repository VatSlipRepository) Create(headerID int64, models []interface{}) } func (repository VatSlipRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatSlipChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.VatSlipChecked) } func (repository *VatSlipRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/vat_toll/repository.go b/pkg/transformers/vat_toll/repository.go index 6c738e54..2c9be8a4 100644 --- a/pkg/transformers/vat_toll/repository.go +++ b/pkg/transformers/vat_toll/repository.go @@ -34,7 +34,7 @@ func (repository VatTollRepository) Create(headerID int64, models []interface{}) } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatTollChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatTollChecked) if err != nil { tx.Rollback() return err @@ -43,7 +43,7 @@ func (repository VatTollRepository) Create(headerID int64, models []interface{}) } func (repository VatTollRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatTollChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.VatTollChecked) } func (repository *VatTollRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/vat_tune/repository.go b/pkg/transformers/vat_tune/repository.go index 79404cb0..c9951ce6 100644 --- a/pkg/transformers/vat_tune/repository.go +++ b/pkg/transformers/vat_tune/repository.go @@ -34,7 +34,7 @@ func (repository VatTuneRepository) Create(headerID int64, models []interface{}) } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatTuneChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatTuneChecked) if err != nil { tx.Rollback() return err @@ -43,7 +43,7 @@ func (repository VatTuneRepository) Create(headerID int64, models []interface{}) } func (repository VatTuneRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatTuneChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.VatTuneChecked) } func (repository *VatTuneRepository) SetDB(db *postgres.DB) { diff --git a/pkg/transformers/vow_flog/repository.go b/pkg/transformers/vow_flog/repository.go index 994de3e2..48076802 100644 --- a/pkg/transformers/vow_flog/repository.go +++ b/pkg/transformers/vow_flog/repository.go @@ -50,7 +50,7 @@ func (repository VowFlogRepository) Create(headerID int64, models []interface{}) } } - err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VowFlogChecked) + err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VowFlogChecked) if err != nil { tx.Rollback() return err @@ -60,7 +60,7 @@ func (repository VowFlogRepository) Create(headerID int64, models []interface{}) } func (repository VowFlogRepository) MarkHeaderChecked(headerID int64) error { - return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VowFlogChecked) + return shared.MarkHeaderChecked(headerID, repository.db, constants.VowFlogChecked) } func (repository *VowFlogRepository) SetDB(db *postgres.DB) {