Skip to content

Commit

Permalink
misc: remove redundant casting
Browse files Browse the repository at this point in the history
  • Loading branch information
invis-bitfly committed Jan 8, 2025
1 parent 8e7f751 commit 04b67b9
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 548 deletions.
20 changes: 1 addition & 19 deletions backend/cmd/eth1indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,7 @@ func Run() {
}()
}

db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Name: cfg.WriterDatabase.Name,
Host: cfg.WriterDatabase.Host,
Port: cfg.WriterDatabase.Port,
MaxOpenConns: cfg.WriterDatabase.MaxOpenConns,
MaxIdleConns: cfg.WriterDatabase.MaxIdleConns,
SSL: cfg.WriterDatabase.SSL,
}, &types.DatabaseConfig{
Username: cfg.ReaderDatabase.Username,
Password: cfg.ReaderDatabase.Password,
Name: cfg.ReaderDatabase.Name,
Host: cfg.ReaderDatabase.Host,
Port: cfg.ReaderDatabase.Port,
MaxOpenConns: cfg.ReaderDatabase.MaxOpenConns,
MaxIdleConns: cfg.ReaderDatabase.MaxIdleConns,
SSL: cfg.ReaderDatabase.SSL,
}, "pgx", "postgres")
db.WriterDb, db.ReaderDb = db.MustInitDB(&cfg.WriterDatabase, &cfg.ReaderDatabase, "pgx", "postgres")
defer db.ReaderDb.Close()
defer db.WriterDb.Close()

Expand Down
20 changes: 1 addition & 19 deletions backend/cmd/ethstore_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,7 @@ func Run() {
}()
}

db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Name: cfg.WriterDatabase.Name,
Host: cfg.WriterDatabase.Host,
Port: cfg.WriterDatabase.Port,
MaxOpenConns: cfg.WriterDatabase.MaxOpenConns,
MaxIdleConns: cfg.WriterDatabase.MaxIdleConns,
SSL: cfg.WriterDatabase.SSL,
}, &types.DatabaseConfig{
Username: cfg.ReaderDatabase.Username,
Password: cfg.ReaderDatabase.Password,
Name: cfg.ReaderDatabase.Name,
Host: cfg.ReaderDatabase.Host,
Port: cfg.ReaderDatabase.Port,
MaxOpenConns: cfg.ReaderDatabase.MaxOpenConns,
MaxIdleConns: cfg.ReaderDatabase.MaxIdleConns,
SSL: cfg.ReaderDatabase.SSL,
}, "pgx", "postgres")
db.WriterDb, db.ReaderDb = db.MustInitDB(&cfg.WriterDatabase, &cfg.WriterDatabase, "pgx", "postgres")
defer db.ReaderDb.Close()
defer db.WriterDb.Close()

Expand Down
20 changes: 1 addition & 19 deletions backend/cmd/evm_node_indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,7 @@ func Run() {

// init postgres
{
db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: utils.Config.WriterDatabase.Username,
Password: utils.Config.WriterDatabase.Password,
Name: utils.Config.WriterDatabase.Name,
Host: utils.Config.WriterDatabase.Host,
Port: utils.Config.WriterDatabase.Port,
MaxOpenConns: utils.Config.WriterDatabase.MaxOpenConns,
MaxIdleConns: utils.Config.WriterDatabase.MaxIdleConns,
SSL: utils.Config.WriterDatabase.SSL,
}, &types.DatabaseConfig{
Username: utils.Config.ReaderDatabase.Username,
Password: utils.Config.ReaderDatabase.Password,
Name: utils.Config.ReaderDatabase.Name,
Host: utils.Config.ReaderDatabase.Host,
Port: utils.Config.ReaderDatabase.Port,
MaxOpenConns: utils.Config.ReaderDatabase.MaxOpenConns,
MaxIdleConns: utils.Config.ReaderDatabase.MaxIdleConns,
SSL: utils.Config.ReaderDatabase.SSL,
}, "pgx", "postgres")
db.WriterDb, db.ReaderDb = db.MustInitDB(&utils.Config.WriterDatabase, &utils.Config.ReaderDatabase, "pgx", "postgres")
defer db.ReaderDb.Close()
defer db.WriterDb.Close()
log.Info("starting postgres completed")
Expand Down
40 changes: 2 additions & 38 deletions backend/cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,7 @@ func Run() {
wg.Add(1)
go func() {
defer wg.Done()
db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Name: cfg.WriterDatabase.Name,
Host: cfg.WriterDatabase.Host,
Port: cfg.WriterDatabase.Port,
MaxOpenConns: cfg.WriterDatabase.MaxOpenConns,
MaxIdleConns: cfg.WriterDatabase.MaxIdleConns,
SSL: cfg.WriterDatabase.SSL,
}, &types.DatabaseConfig{
Username: cfg.ReaderDatabase.Username,
Password: cfg.ReaderDatabase.Password,
Name: cfg.ReaderDatabase.Name,
Host: cfg.ReaderDatabase.Host,
Port: cfg.ReaderDatabase.Port,
MaxOpenConns: cfg.ReaderDatabase.MaxOpenConns,
MaxIdleConns: cfg.ReaderDatabase.MaxIdleConns,
SSL: cfg.ReaderDatabase.SSL,
}, "pgx", "postgres")
db.WriterDb, db.ReaderDb = db.MustInitDB(&cfg.WriterDatabase, &cfg.ReaderDatabase, "pgx", "postgres")
}()
} else {
log.Warnf("------- EXPORTER RUNNING IN V2 ONLY MODE ------")
Expand All @@ -84,25 +66,7 @@ func Run() {
wg.Add(1)
go func() {
defer wg.Done()
db.AlloyWriter, db.AlloyReader = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.AlloyWriter.Username,
Password: cfg.AlloyWriter.Password,
Name: cfg.AlloyWriter.Name,
Host: cfg.AlloyWriter.Host,
Port: cfg.AlloyWriter.Port,
MaxOpenConns: cfg.AlloyWriter.MaxOpenConns,
MaxIdleConns: cfg.AlloyWriter.MaxIdleConns,
SSL: cfg.AlloyWriter.SSL,
}, &types.DatabaseConfig{
Username: cfg.AlloyReader.Username,
Password: cfg.AlloyReader.Password,
Name: cfg.AlloyReader.Name,
Host: cfg.AlloyReader.Host,
Port: cfg.AlloyReader.Port,
MaxOpenConns: cfg.AlloyReader.MaxOpenConns,
MaxIdleConns: cfg.AlloyReader.MaxIdleConns,
SSL: cfg.AlloyReader.SSL,
}, "pgx", "postgres")
db.AlloyWriter, db.AlloyReader = db.MustInitDB(&cfg.AlloyWriter, &cfg.AlloyReader, "pgx", "postgres")
}()

wg.Add(1)
Expand Down
78 changes: 4 additions & 74 deletions backend/cmd/misc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,92 +180,22 @@ func Run() {
}

if requires.NetworkDBs {
db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Name: cfg.WriterDatabase.Name,
Host: cfg.WriterDatabase.Host,
Port: cfg.WriterDatabase.Port,
MaxOpenConns: cfg.WriterDatabase.MaxOpenConns,
MaxIdleConns: cfg.WriterDatabase.MaxIdleConns,
SSL: cfg.WriterDatabase.SSL,
}, &types.DatabaseConfig{
Username: cfg.ReaderDatabase.Username,
Password: cfg.ReaderDatabase.Password,
Name: cfg.ReaderDatabase.Name,
Host: cfg.ReaderDatabase.Host,
Port: cfg.ReaderDatabase.Port,
MaxOpenConns: cfg.ReaderDatabase.MaxOpenConns,
MaxIdleConns: cfg.ReaderDatabase.MaxIdleConns,
SSL: cfg.ReaderDatabase.SSL,
}, "pgx", "postgres")
db.WriterDb, db.ReaderDb = db.MustInitDB(&cfg.WriterDatabase, &cfg.ReaderDatabase, "pgx", "postgres")
defer db.ReaderDb.Close()
defer db.WriterDb.Close()

db.AlloyWriter, db.AlloyReader = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.AlloyWriter.Username,
Password: cfg.AlloyWriter.Password,
Name: cfg.AlloyWriter.Name,
Host: cfg.AlloyWriter.Host,
Port: cfg.AlloyWriter.Port,
MaxOpenConns: cfg.AlloyWriter.MaxOpenConns,
MaxIdleConns: cfg.AlloyWriter.MaxIdleConns,
SSL: cfg.AlloyWriter.SSL,
}, &types.DatabaseConfig{
Username: cfg.AlloyReader.Username,
Password: cfg.AlloyReader.Password,
Name: cfg.AlloyReader.Name,
Host: cfg.AlloyReader.Host,
Port: cfg.AlloyReader.Port,
MaxOpenConns: cfg.AlloyReader.MaxOpenConns,
MaxIdleConns: cfg.AlloyReader.MaxIdleConns,
SSL: cfg.AlloyReader.SSL,
}, "pgx", "postgres")
db.AlloyWriter, db.AlloyReader = db.MustInitDB(&cfg.AlloyWriter, &cfg.AlloyReader, "pgx", "postgres")
defer db.AlloyReader.Close()
defer db.AlloyWriter.Close()
}
if requires.UserDBs {
db.FrontendWriterDB, db.FrontendReaderDB = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.Frontend.WriterDatabase.Username,
Password: cfg.Frontend.WriterDatabase.Password,
Name: cfg.Frontend.WriterDatabase.Name,
Host: cfg.Frontend.WriterDatabase.Host,
Port: cfg.Frontend.WriterDatabase.Port,
MaxOpenConns: cfg.Frontend.WriterDatabase.MaxOpenConns,
MaxIdleConns: cfg.Frontend.WriterDatabase.MaxIdleConns,
}, &types.DatabaseConfig{
Username: cfg.Frontend.ReaderDatabase.Username,
Password: cfg.Frontend.ReaderDatabase.Password,
Name: cfg.Frontend.ReaderDatabase.Name,
Host: cfg.Frontend.ReaderDatabase.Host,
Port: cfg.Frontend.ReaderDatabase.Port,
MaxOpenConns: cfg.Frontend.ReaderDatabase.MaxOpenConns,
MaxIdleConns: cfg.Frontend.ReaderDatabase.MaxIdleConns,
}, "pgx", "postgres")
db.FrontendWriterDB, db.FrontendReaderDB = db.MustInitDB(&cfg.Frontend.WriterDatabase, &cfg.Frontend.ReaderDatabase, "pgx", "postgres")
defer db.FrontendReaderDB.Close()
defer db.FrontendWriterDB.Close()
}

// clickhouse
db.ClickHouseWriter, db.ClickHouseReader = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.ClickHouse.WriterDatabase.Username,
Password: cfg.ClickHouse.WriterDatabase.Password,
Name: cfg.ClickHouse.WriterDatabase.Name,
Host: cfg.ClickHouse.WriterDatabase.Host,
Port: cfg.ClickHouse.WriterDatabase.Port,
MaxOpenConns: cfg.ClickHouse.WriterDatabase.MaxOpenConns,
SSL: true,
MaxIdleConns: cfg.ClickHouse.WriterDatabase.MaxIdleConns,
}, &types.DatabaseConfig{
Username: cfg.ClickHouse.ReaderDatabase.Username,
Password: cfg.ClickHouse.ReaderDatabase.Password,
Name: cfg.ClickHouse.ReaderDatabase.Name,
Host: cfg.ClickHouse.ReaderDatabase.Host,
Port: cfg.ClickHouse.ReaderDatabase.Port,
MaxOpenConns: cfg.ClickHouse.ReaderDatabase.MaxOpenConns,
SSL: true,
MaxIdleConns: cfg.ClickHouse.ReaderDatabase.MaxIdleConns,
}, "clickhouse", "clickhouse")
db.ClickHouseWriter, db.ClickHouseReader = db.MustInitDB(&cfg.ClickHouse.WriterDatabase, &cfg.ClickHouse.ReaderDatabase, "clickhouse", "clickhouse")
defer db.ClickHouseReader.Close()
defer db.ClickHouseWriter.Close()

Expand Down
20 changes: 1 addition & 19 deletions backend/cmd/monitoring/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,7 @@ func Run() {
}()
}

db.ClickHouseWriter, db.ClickHouseReader = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.ClickHouse.WriterDatabase.Username,
Password: cfg.ClickHouse.WriterDatabase.Password,
Name: cfg.ClickHouse.WriterDatabase.Name,
Host: cfg.ClickHouse.WriterDatabase.Host,
Port: cfg.ClickHouse.WriterDatabase.Port,
MaxOpenConns: cfg.ClickHouse.WriterDatabase.MaxOpenConns,
SSL: true,
MaxIdleConns: cfg.ClickHouse.WriterDatabase.MaxIdleConns,
}, &types.DatabaseConfig{
Username: cfg.ClickHouse.ReaderDatabase.Username,
Password: cfg.ClickHouse.ReaderDatabase.Password,
Name: cfg.ClickHouse.ReaderDatabase.Name,
Host: cfg.ClickHouse.ReaderDatabase.Host,
Port: cfg.ClickHouse.ReaderDatabase.Port,
MaxOpenConns: cfg.ClickHouse.ReaderDatabase.MaxOpenConns,
SSL: true,
MaxIdleConns: cfg.ClickHouse.ReaderDatabase.MaxIdleConns,
}, "clickhouse", "clickhouse")
db.ClickHouseWriter, db.ClickHouseReader = db.MustInitDB(&cfg.ClickHouse.WriterDatabase, &cfg.ClickHouse.ReaderDatabase, "clickhouse", "clickhouse")
defer db.ClickHouseReader.Close()
defer db.ClickHouseWriter.Close()

Expand Down
20 changes: 1 addition & 19 deletions backend/cmd/node_jobs_processor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,7 @@ func Run() {
}()
}

db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Name: cfg.WriterDatabase.Name,
Host: cfg.WriterDatabase.Host,
Port: cfg.WriterDatabase.Port,
MaxOpenConns: cfg.WriterDatabase.MaxOpenConns,
MaxIdleConns: cfg.WriterDatabase.MaxIdleConns,
SSL: cfg.WriterDatabase.SSL,
}, &types.DatabaseConfig{
Username: cfg.ReaderDatabase.Username,
Password: cfg.ReaderDatabase.Password,
Name: cfg.ReaderDatabase.Name,
Host: cfg.ReaderDatabase.Host,
Port: cfg.ReaderDatabase.Port,
MaxOpenConns: cfg.ReaderDatabase.MaxOpenConns,
MaxIdleConns: cfg.ReaderDatabase.MaxIdleConns,
SSL: cfg.ReaderDatabase.SSL,
}, "pgx", "postgres")
db.WriterDb, db.ReaderDb = db.MustInitDB(&cfg.WriterDatabase, &cfg.ReaderDatabase, "pgx", "postgres")
defer db.ReaderDb.Close()
defer db.WriterDb.Close()

Expand Down
78 changes: 4 additions & 74 deletions backend/cmd/notification_collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,96 +83,26 @@ func Run() {
wg.Add(1)
go func() {
defer wg.Done()
db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Name: cfg.WriterDatabase.Name,
Host: cfg.WriterDatabase.Host,
Port: cfg.WriterDatabase.Port,
MaxOpenConns: cfg.WriterDatabase.MaxOpenConns,
MaxIdleConns: cfg.WriterDatabase.MaxIdleConns,
SSL: cfg.WriterDatabase.SSL,
}, &types.DatabaseConfig{
Username: cfg.ReaderDatabase.Username,
Password: cfg.ReaderDatabase.Password,
Name: cfg.ReaderDatabase.Name,
Host: cfg.ReaderDatabase.Host,
Port: cfg.ReaderDatabase.Port,
MaxOpenConns: cfg.ReaderDatabase.MaxOpenConns,
MaxIdleConns: cfg.ReaderDatabase.MaxIdleConns,
SSL: cfg.ReaderDatabase.SSL,
}, "pgx", "postgres")
db.WriterDb, db.ReaderDb = db.MustInitDB(&cfg.WriterDatabase, &cfg.ReaderDatabase, "pgx", "postgres")
}()

wg.Add(1)
go func() {
defer wg.Done()
db.AlloyWriter, db.AlloyReader = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.AlloyWriter.Username,
Password: cfg.AlloyWriter.Password,
Name: cfg.AlloyWriter.Name,
Host: cfg.AlloyWriter.Host,
Port: cfg.AlloyWriter.Port,
MaxOpenConns: cfg.AlloyWriter.MaxOpenConns,
MaxIdleConns: cfg.AlloyWriter.MaxIdleConns,
SSL: cfg.AlloyWriter.SSL,
}, &types.DatabaseConfig{
Username: cfg.AlloyReader.Username,
Password: cfg.AlloyReader.Password,
Name: cfg.AlloyReader.Name,
Host: cfg.AlloyReader.Host,
Port: cfg.AlloyReader.Port,
MaxOpenConns: cfg.AlloyReader.MaxOpenConns,
MaxIdleConns: cfg.AlloyReader.MaxIdleConns,
SSL: cfg.AlloyReader.SSL,
}, "pgx", "postgres")
db.AlloyWriter, db.AlloyReader = db.MustInitDB(&cfg.AlloyWriter, &cfg.AlloyReader, "pgx", "postgres")
}()

wg.Add(1)
go func() {
defer wg.Done()
db.FrontendWriterDB, db.FrontendReaderDB = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.Frontend.WriterDatabase.Username,
Password: cfg.Frontend.WriterDatabase.Password,
Name: cfg.Frontend.WriterDatabase.Name,
Host: cfg.Frontend.WriterDatabase.Host,
Port: cfg.Frontend.WriterDatabase.Port,
MaxOpenConns: cfg.Frontend.WriterDatabase.MaxOpenConns,
MaxIdleConns: cfg.Frontend.WriterDatabase.MaxIdleConns,
}, &types.DatabaseConfig{
Username: cfg.Frontend.ReaderDatabase.Username,
Password: cfg.Frontend.ReaderDatabase.Password,
Name: cfg.Frontend.ReaderDatabase.Name,
Host: cfg.Frontend.ReaderDatabase.Host,
Port: cfg.Frontend.ReaderDatabase.Port,
MaxOpenConns: cfg.Frontend.ReaderDatabase.MaxOpenConns,
MaxIdleConns: cfg.Frontend.ReaderDatabase.MaxIdleConns,
}, "pgx", "postgres")
db.FrontendWriterDB, db.FrontendReaderDB = db.MustInitDB(&cfg.Frontend.WriterDatabase, &cfg.Frontend.ReaderDatabase, "pgx", "postgres")
}()

wg.Add(1)
go func() {
defer wg.Done()
// clickhouse
db.ClickHouseWriter, db.ClickHouseReader = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.ClickHouse.WriterDatabase.Username,
Password: cfg.ClickHouse.WriterDatabase.Password,
Name: cfg.ClickHouse.WriterDatabase.Name,
Host: cfg.ClickHouse.WriterDatabase.Host,
Port: cfg.ClickHouse.WriterDatabase.Port,
MaxOpenConns: cfg.ClickHouse.WriterDatabase.MaxOpenConns,
SSL: true,
MaxIdleConns: cfg.ClickHouse.WriterDatabase.MaxIdleConns,
}, &types.DatabaseConfig{
Username: cfg.ClickHouse.ReaderDatabase.Username,
Password: cfg.ClickHouse.ReaderDatabase.Password,
Name: cfg.ClickHouse.ReaderDatabase.Name,
Host: cfg.ClickHouse.ReaderDatabase.Host,
Port: cfg.ClickHouse.ReaderDatabase.Port,
MaxOpenConns: cfg.ClickHouse.ReaderDatabase.MaxOpenConns,
SSL: true,
MaxIdleConns: cfg.ClickHouse.ReaderDatabase.MaxIdleConns,
}, "clickhouse", "clickhouse")
db.ClickHouseWriter, db.ClickHouseReader = db.MustInitDB(&cfg.ClickHouse.WriterDatabase, &cfg.ClickHouse.ReaderDatabase, "clickhouse", "clickhouse")
}()

wg.Add(1)
Expand Down
Loading

0 comments on commit 04b67b9

Please sign in to comment.