diff --git a/internal/data/pg/balances.go b/internal/data/pg/balances.go index d183152..6388712 100644 --- a/internal/data/pg/balances.go +++ b/internal/data/pg/balances.go @@ -28,7 +28,7 @@ func NewBalances(db *pgdb.DB) data.BalancesQ { } func (q *balances) New() data.BalancesQ { - return NewBalances(q.db.Clone()) + return NewBalances(q.db) } func (q *balances) Insert(bal data.Balance) error { diff --git a/internal/data/pg/events.go b/internal/data/pg/events.go index 0c2d58c..6fe4d7d 100644 --- a/internal/data/pg/events.go +++ b/internal/data/pg/events.go @@ -35,7 +35,7 @@ func NewEvents(db *pgdb.DB) data.EventsQ { } func (q *events) New() data.EventsQ { - return NewEvents(q.db.Clone()) + return NewEvents(q.db) } func (q *events) Insert(events ...data.Event) error { diff --git a/internal/data/pg/withdrawals.go b/internal/data/pg/withdrawals.go index 461ca49..638823d 100644 --- a/internal/data/pg/withdrawals.go +++ b/internal/data/pg/withdrawals.go @@ -23,7 +23,7 @@ func NewWithdrawals(db *pgdb.DB) data.WithdrawalsQ { } func (q *withdrawals) New() data.WithdrawalsQ { - return NewWithdrawals(q.db.Clone()) + return NewWithdrawals(q.db) } func (q *withdrawals) Insert(w data.Withdrawal) (*data.Withdrawal, error) { diff --git a/internal/service/router.go b/internal/service/router.go index ced93c4..8c3a8bc 100644 --- a/internal/service/router.go +++ b/internal/service/router.go @@ -12,15 +12,16 @@ import ( func Run(ctx context.Context, cfg config.Config) { r := chi.NewRouter() + db := cfg.DB().Clone() r.Use( ape.RecoverMiddleware(cfg.Log()), ape.LoganMiddleware(cfg.Log()), ape.CtxMiddleware( handlers.CtxLog(cfg.Log()), - handlers.CtxEventsQ(pg.NewEvents(cfg.DB())), - handlers.CtxBalancesQ(pg.NewBalances(cfg.DB())), - handlers.CtxWithdrawalsQ(pg.NewWithdrawals(cfg.DB())), + handlers.CtxEventsQ(pg.NewEvents(db)), + handlers.CtxBalancesQ(pg.NewBalances(db)), + handlers.CtxWithdrawalsQ(pg.NewWithdrawals(db)), handlers.CtxEventTypes(cfg.EventTypes()), handlers.CtxBroadcaster(cfg.Broadcaster()), handlers.CtxPointPrice(cfg.PointPrice()), diff --git a/internal/service/workers/reopener/init.go b/internal/service/workers/reopener/init.go index 763d2c7..7085f5c 100644 --- a/internal/service/workers/reopener/init.go +++ b/internal/service/workers/reopener/init.go @@ -13,7 +13,7 @@ import ( func initialRun(cfg config.Config) error { var ( - q = pg.NewEvents(cfg.DB()) + q = pg.NewEvents(cfg.DB().Clone()) log = cfg.Log().WithField("who", "reopener[initializer]") col = &initCollector{ q: q, diff --git a/internal/service/workers/sbtcheck/main.go b/internal/service/workers/sbtcheck/main.go index 5d39cb9..d3b189a 100644 --- a/internal/service/workers/sbtcheck/main.go +++ b/internal/service/workers/sbtcheck/main.go @@ -76,7 +76,7 @@ func Run(ctx context.Context, cfg extConfig) { r := &runner{ network: net, - db: cfg.DB(), + db: cfg.DB().Clone(), types: cfg.EventTypes(), log: log.WithField("network", name), cancel: cancel,