From f1e74961b01192496a02fe2e6e8a504a87a4ec15 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Wed, 11 Jan 2023 08:42:00 +0000 Subject: [PATCH] fix: deepsource suggestions --- cmd/filters.go | 5 ----- cmd/main.go | 2 +- go.mod | 2 +- internal/api/stats.go | 2 -- internal/api/types.go | 5 ----- internal/filter/address_filter.go | 2 +- internal/filter/noop_filter.go | 2 +- internal/filter/transfer_filter.go | 2 +- internal/pipeline/pipeline_test.go | 4 ++-- 9 files changed, 7 insertions(+), 19 deletions(-) diff --git a/cmd/filters.go b/cmd/filters.go index c79a3e7..088c126 100644 --- a/cmd/filters.go +++ b/cmd/filters.go @@ -16,8 +16,3 @@ func initTransferFilter() filter.Filter { }) } -func initNoopFilter() filter.Filter { - return filter.NewNoopFilter(filter.NoopFilterOpts{ - Logg: lo, - }) -} diff --git a/cmd/main.go b/cmd/main.go index b679dc3..e58cce5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -89,7 +89,7 @@ func main() { SweepInterval: time.Second * time.Duration(ko.MustInt64("syncer.sweep_interval")), }) - apiServer.GET("/stats", api.StatsHandler(syncerStats, workerPool, lo)) + apiServer.GET("/stats", api.StatsHandler(syncerStats, workerPool)) wg.Add(1) go func() { diff --git a/go.mod b/go.mod index 816b124..b7cfc58 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/VictoriaMetrics/metrics v1.23.0 github.com/alitto/pond v1.8.2 github.com/celo-org/celo-blockchain v1.6.1 + github.com/goccy/go-json v0.10.0 github.com/jackc/pgx/v5 v5.2.0 github.com/knadh/goyesql/v2 v2.2.0 github.com/knadh/koanf v1.4.5 @@ -23,7 +24,6 @@ require ( github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/go-ole/go-ole v1.2.5 // indirect github.com/go-stack/stack v1.8.0 // indirect - github.com/goccy/go-json v0.10.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect diff --git a/internal/api/stats.go b/internal/api/stats.go index da35c34..aa76e47 100644 --- a/internal/api/stats.go +++ b/internal/api/stats.go @@ -6,7 +6,6 @@ import ( "github.com/alitto/pond" "github.com/grassrootseconomics/cic-chain-events/internal/syncer" "github.com/labstack/echo/v4" - "github.com/zerodha/logf" ) type statsResponse struct { @@ -22,7 +21,6 @@ type statsResponse struct { func StatsHandler( syncerStats *syncer.Stats, poolStats *pond.WorkerPool, - logg logf.Logger, ) func(echo.Context) error { return func(ctx echo.Context) error { headCursor := syncerStats.GetHeadCursor() diff --git a/internal/api/types.go b/internal/api/types.go index c115612..5d842a0 100644 --- a/internal/api/types.go +++ b/internal/api/types.go @@ -8,8 +8,3 @@ type okResp struct { Ok bool `json:"ok"` Data interface{} `json:"data"` } - -type errResp struct { - Ok bool `json:"ok"` - Error string `json:"error"` -} diff --git a/internal/filter/address_filter.go b/internal/filter/address_filter.go index a3594f8..2d04eac 100644 --- a/internal/filter/address_filter.go +++ b/internal/filter/address_filter.go @@ -25,7 +25,7 @@ func NewAddressFilter(o AddressFilterOpts) Filter { } } -func (f *AddressFilter) Execute(ctx context.Context, transaction fetch.Transaction) (bool, error) { +func (*AddressFilter) Execute(_ context.Context, transaction fetch.Transaction) (bool, error) { if transaction.To.Address == cUSD { return true, nil } diff --git a/internal/filter/noop_filter.go b/internal/filter/noop_filter.go index 75f213d..e7ff2d5 100644 --- a/internal/filter/noop_filter.go +++ b/internal/filter/noop_filter.go @@ -21,7 +21,7 @@ func NewNoopFilter(o NoopFilterOpts) Filter { } } -func (f *NoopFilter) Execute(ctx context.Context, transaction fetch.Transaction) (bool, error) { +func (f *NoopFilter) Execute(_ context.Context, transaction fetch.Transaction) (bool, error) { f.logg.Debug("noop filter", "block", transaction.Block.Number, "index", transaction.Index) return true, nil } diff --git a/internal/filter/transfer_filter.go b/internal/filter/transfer_filter.go index daf2857..e76e625 100644 --- a/internal/filter/transfer_filter.go +++ b/internal/filter/transfer_filter.go @@ -21,7 +21,7 @@ func NewTransferFilter(o TransferFilterOpts) Filter { } } -func (f *TransferFilter) Execute(ctx context.Context, transaction fetch.Transaction) (bool, error) { +func (f *TransferFilter) Execute(_ context.Context, transaction fetch.Transaction) (bool, error) { switch transaction.InputData[:10] { case "0xa9059cbb": f.logg.Info("cUSD transfer", "block", transaction.Block.Number, "index", transaction.Index) diff --git a/internal/pipeline/pipeline_test.go b/internal/pipeline/pipeline_test.go index 87a06b7..0db04cb 100644 --- a/internal/pipeline/pipeline_test.go +++ b/internal/pipeline/pipeline_test.go @@ -33,7 +33,7 @@ func newErrorFilter() filter.Filter { return &errorFilter{} } -func (f *errorFilter) Execute(ctx context.Context, transaction fetch.Transaction) (bool, error) { +func (*errorFilter) Execute(_ context.Context, _ fetch.Transaction) (bool, error) { return false, errors.New("crash") } @@ -43,7 +43,7 @@ func newEarlyExitFilter() filter.Filter { return &earlyExitFilter{} } -func (f *earlyExitFilter) Execute(ctx context.Context, transaction fetch.Transaction) (bool, error) { +func (*earlyExitFilter) Execute(_ context.Context, _ fetch.Transaction) (bool, error) { return false, nil }