Skip to content

Commit

Permalink
Linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Oct 2, 2024
1 parent 4f8d6bd commit ddeb0b4
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions services/balances/batch/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (s *Service) updateOnRestart(ctx context.Context, startHeight int64) {
s.catchup(ctx, md)
log.Info().Msg("Caught up")

runtimeFunc := func(_ context.Context, _ interface{}) (time.Time, error) {
runtimeFunc := func(_ context.Context, _ any) (time.Time, error) {
return time.Now().Add(s.interval), nil
}

Expand All @@ -125,7 +125,7 @@ func (s *Service) updateOnRestart(ctx context.Context, startHeight int64) {
}
}

func (s *Service) updateOnScheduleTick(ctx context.Context, _ interface{}) {
func (s *Service) updateOnScheduleTick(ctx context.Context, _ any) {
// Only allow 1 handler to be active.
acquired := s.activitySem.TryAcquire(1)
if !acquired {
Expand Down
4 changes: 2 additions & 2 deletions services/blockrewards/batch/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *Service) updateOnRestart(ctx context.Context, startHeight int64) {
s.catchup(ctx, md)
log.Info().Int64("height", md.LatestHeight).Msg("Caught up; starting periodic update")

runtimeFunc := func(_ context.Context, _ interface{}) (time.Time, error) {
runtimeFunc := func(_ context.Context, _ any) (time.Time, error) {
return time.Now().Add(s.interval), nil
}

Expand All @@ -103,7 +103,7 @@ func (s *Service) updateOnRestart(ctx context.Context, startHeight int64) {
}
}

func (s *Service) updateOnScheduleTick(ctx context.Context, _ interface{}) {
func (s *Service) updateOnScheduleTick(ctx context.Context, _ any) {
// Only allow 1 handler to be active.
acquired := s.activitySem.TryAcquire(1)
if !acquired {
Expand Down
2 changes: 1 addition & 1 deletion services/blocks/batch/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (s *Service) catchup(ctx context.Context, md *metadata) {
stateDiffs: make([]*execdb.TransactionStateDiff, 0),
}

if _, err = util.Scatter(int(entries), int(s.processConcurrency), func(offset int, entries int, mu *sync.RWMutex) (interface{}, error) {
if _, err = util.Scatter(int(entries), int(s.processConcurrency), func(offset int, entries int, mu *sync.RWMutex) (any, error) {
for i := offset; i < offset+entries; i++ {
log.Trace().Uint32("height", blockHeights[i]).Msg("Fetching block")
block, err := s.blocksProvider.Block(ctx, fmt.Sprintf("%d", blockHeights[i]))
Expand Down
4 changes: 2 additions & 2 deletions services/blocks/batch/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (s *Service) updateOnRestart(ctx context.Context, startHeight int64) {
s.catchup(ctx, md)
log.Info().Int64("height", md.LatestHeight).Msg("Caught up; starting periodic update")

runtimeFunc := func(_ context.Context, _ interface{}) (time.Time, error) {
runtimeFunc := func(_ context.Context, _ any) (time.Time, error) {
return time.Now().Add(s.interval), nil
}

Expand All @@ -124,7 +124,7 @@ func (s *Service) updateOnRestart(ctx context.Context, startHeight int64) {
}
}

func (s *Service) updateOnScheduleTick(ctx context.Context, _ interface{}) {
func (s *Service) updateOnScheduleTick(ctx context.Context, _ any) {
// Only allow 1 handler to be active.
acquired := s.activitySem.TryAcquire(1)
if !acquired {
Expand Down
4 changes: 2 additions & 2 deletions services/blocks/individual/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (s *Service) updateOnRestart(ctx context.Context, startHeight int64) {
s.catchup(ctx, md)
log.Info().Msg("Caught up; starting periodic update")

runtimeFunc := func(_ context.Context, _ interface{}) (time.Time, error) {
runtimeFunc := func(_ context.Context, _ any) (time.Time, error) {
return time.Now().Add(s.interval), nil
}

Expand All @@ -122,7 +122,7 @@ func (s *Service) updateOnRestart(ctx context.Context, startHeight int64) {
}
}

func (s *Service) updateOnScheduleTick(ctx context.Context, _ interface{}) {
func (s *Service) updateOnScheduleTick(ctx context.Context, _ any) {
// Only allow 1 handler to be active.
acquired := s.activitySem.TryAcquire(1)
if !acquired {
Expand Down
2 changes: 1 addition & 1 deletion services/execdb/postgresql/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (s *Service) Balances(ctx context.Context, filter *execdb.BalanceFilter) ([

// Build the query.
queryBuilder := strings.Builder{}
queryVals := make([]interface{}, 0)
queryVals := make([]any, 0)

queryBuilder.WriteString(`
SELECT f_address
Expand Down
2 changes: 1 addition & 1 deletion services/execdb/postgresql/blockrewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *Service) BlockRewards(ctx context.Context, filter *execdb.BlockRewardFi

// Build the query.
queryBuilder := strings.Builder{}
queryVals := make([]interface{}, 0)
queryVals := make([]any, 0)

queryBuilder.WriteString(`
SELECT f_block_height
Expand Down
2 changes: 1 addition & 1 deletion services/execdb/postgresql/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *Service) Blocks(ctx context.Context, filter *execdb.BlockFilter) ([]*ex

// Build the query.
queryBuilder := strings.Builder{}
queryVals := make([]interface{}, 0)
queryVals := make([]any, 0)

queryBuilder.WriteString(`
SELECT f_height
Expand Down
2 changes: 1 addition & 1 deletion services/execdb/postgresql/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *Service) Events(ctx context.Context, filter *execdb.EventFilter) ([]*ex

// Build the query.
queryBuilder := strings.Builder{}
queryVals := make([]interface{}, 0)
queryVals := make([]any, 0)

queryBuilder.WriteString(`
SELECT f_transaction_hash
Expand Down
4 changes: 2 additions & 2 deletions services/execdb/postgresql/setbalances.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (s *Service) SetBalances(ctx context.Context, balances []*execdb.Balance) e
"f_from",
"f_amount",
},
pgx.CopyFromSlice(len(balances), func(i int) ([]interface{}, error) {
return []interface{}{
pgx.CopyFromSlice(len(balances), func(i int) ([]any, error) {
return []any{
balances[i].Address[:],
balances[i].Currency,
balances[i].From,
Expand Down
4 changes: 2 additions & 2 deletions services/execdb/postgresql/setblockrewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func (s *Service) SetBlockRewards(ctx context.Context, rewards []*execdb.BlockRe
"f_fees",
"f_payments",
},
pgx.CopyFromSlice(len(rewards), func(i int) ([]interface{}, error) {
return []interface{}{
pgx.CopyFromSlice(len(rewards), func(i int) ([]any, error) {
return []any{
rewards[i].BlockHash,
rewards[i].BlockHeight,
decimal.NewFromBigInt(rewards[i].Fees.ToBig(), 0),
Expand Down
4 changes: 2 additions & 2 deletions services/execdb/postgresql/setblocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *Service) SetBlocks(ctx context.Context, blocks []*execdb.Block) error {
"f_blob_gas_used",
"f_excess_blob_gas",
},
pgx.CopyFromSlice(len(blocks), func(i int) ([]interface{}, error) {
pgx.CopyFromSlice(len(blocks), func(i int) ([]any, error) {
var issuance *decimal.Decimal
if blocks[i].Issuance != nil {
tmp := decimal.NewFromBigInt(blocks[i].Issuance, 0)
Expand All @@ -71,7 +71,7 @@ func (s *Service) SetBlocks(ctx context.Context, blocks []*execdb.Block) error {
if len(blocks[i].ParentBeaconBlockRoot) > 0 {
parentBeaconBlockRoot = blocks[i].ParentBeaconBlockRoot
}
return []interface{}{
return []any{
blocks[i].Height,
blocks[i].Hash,
blocks[i].BaseFee,
Expand Down
4 changes: 2 additions & 2 deletions services/execdb/postgresql/setevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func (s *Service) SetEvents(ctx context.Context, events []*execdb.Event) error {
"f_topics",
"f_data",
},
pgx.CopyFromSlice(len(events), func(i int) ([]interface{}, error) {
return []interface{}{
pgx.CopyFromSlice(len(events), func(i int) ([]any, error) {
return []any{
events[i].TransactionHash,
events[i].BlockHeight,
events[i].Index,
Expand Down
8 changes: 4 additions & 4 deletions services/execdb/postgresql/settransactionstatediffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func (s *Service) SetTransactionStateDiffs(ctx context.Context, stateDiffs []*ex
"f_old",
"f_new",
},
pgx.CopyFromSlice(len(balanceChanges), func(i int) ([]interface{}, error) {
return []interface{}{
pgx.CopyFromSlice(len(balanceChanges), func(i int) ([]any, error) {
return []any{
balanceChanges[i].TransactionHash,
balanceChanges[i].BlockHeight,
balanceChanges[i].Address,
Expand Down Expand Up @@ -120,8 +120,8 @@ func (s *Service) SetTransactionStateDiffs(ctx context.Context, stateDiffs []*ex
"f_storage_address",
"f_value",
},
pgx.CopyFromSlice(len(storageChanges), func(i int) ([]interface{}, error) {
return []interface{}{
pgx.CopyFromSlice(len(storageChanges), func(i int) ([]any, error) {
return []any{
storageChanges[i].TransactionHash,
storageChanges[i].BlockHeight,
storageChanges[i].Address,
Expand Down
2 changes: 1 addition & 1 deletion services/execdb/postgresql/transactionbalancechanges.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *Service) TransactionBalanceChanges(ctx context.Context, filter *execdb.

// Build the query.
queryBuilder := strings.Builder{}
queryVals := make([]interface{}, 0)
queryVals := make([]any, 0)

queryBuilder.WriteString(`
SELECT f_transaction_hash
Expand Down
2 changes: 1 addition & 1 deletion services/execdb/postgresql/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *Service) Transactions(ctx context.Context, filter *execdb.TransactionFi

// Build the query.
queryBuilder := strings.Builder{}
queryVals := make([]interface{}, 0)
queryVals := make([]any, 0)

queryBuilder.WriteString(`
SELECT f_block_height
Expand Down
8 changes: 4 additions & 4 deletions services/scheduler/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
)

// JobFunc is the type for jobs.
type JobFunc func(context.Context, interface{})
type JobFunc func(context.Context, any)

// RuntimeFunc is the type of a function that generates the next runtime.
type RuntimeFunc func(context.Context, interface{}) (time.Time, error)
type RuntimeFunc func(context.Context, any) (time.Time, error)

// ErrNoMoreInstances is returned by the runtime generator when it has no more instances.
var ErrNoMoreInstances = errors.New("no more instances")
Expand Down Expand Up @@ -55,13 +55,13 @@ type Service interface {
// This function returns two cancel funcs. If the first is triggered the job will not run. If the second is triggered the job
// runs immediately.
// Note that if the parent context is cancelled the job wil not run.
ScheduleJob(ctx context.Context, class string, name string, runtime time.Time, job JobFunc, data interface{}) error
ScheduleJob(ctx context.Context, class string, name string, runtime time.Time, job JobFunc, data any) error

// SchedulePeriodicJob schedules a job to run in a loop.
// The loop starts by calling runtimeFunc, which sets the time for the first run.
// Once the time as specified by runtimeFunc is met, jobFunc is called.
// Once jobFunc returns, go back to the beginning of the loop.
SchedulePeriodicJob(ctx context.Context, class string, name string, runtime RuntimeFunc, runtimeData interface{}, job JobFunc, jobData interface{}) error
SchedulePeriodicJob(ctx context.Context, class string, name string, runtime RuntimeFunc, runtimeData any, job JobFunc, jobData any) error

// CancelJob cancels a known job.
// If this is a period job then all future instances are cancelled.
Expand Down
4 changes: 2 additions & 2 deletions util/scatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ type ScatterResult struct {
// Offset is the offset at which the worker started.
Offset int
// Extent is the user-defined result of running the scatter function.
Extent interface{}
Extent any
}

// Scatter scatters a computation across multiple goroutines, returning a set of per-worker results.
func Scatter(inputLen int, concurrency int, work func(int, int, *sync.RWMutex) (interface{}, error)) ([]*ScatterResult, error) {
func Scatter(inputLen int, concurrency int, work func(int, int, *sync.RWMutex) (any, error)) ([]*ScatterResult, error) {
if inputLen <= 0 {
return nil, errors.New("no data with which to work")
}
Expand Down
2 changes: 1 addition & 1 deletion util/scatter_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func BenchmarkHash(b *testing.B) {
func BenchmarkHashMP(b *testing.B) {
output := make([][]byte, len(input))
for i := 0; i < b.N; i++ {
workerResults, err := util.Scatter(len(input), runtime.GOMAXPROCS(0), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) {
workerResults, err := util.Scatter(len(input), runtime.GOMAXPROCS(0), func(offset int, entries int, _ *sync.RWMutex) (any, error) {
return hash(input[offset : offset+entries]), nil
})
require.NoError(b, err)
Expand Down
6 changes: 3 additions & 3 deletions util/scatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestDouble(t *testing.T) {
inValues[i] = i
}
outValues := make([]int, test.inValues)
workerResults, err := util.Scatter(len(inValues), runtime.GOMAXPROCS(0), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) {
workerResults, err := util.Scatter(len(inValues), runtime.GOMAXPROCS(0), func(offset int, entries int, _ *sync.RWMutex) (any, error) {
extent := make([]int, entries)
for i := 0; i < entries; i++ {
extent[i] = inValues[offset+i] * 2
Expand All @@ -86,7 +86,7 @@ func TestDouble(t *testing.T) {
func TestMutex(t *testing.T) {
totalRuns := 1048576
val := 0
_, err := util.Scatter(totalRuns, runtime.GOMAXPROCS(0), func(offset int, entries int, mu *sync.RWMutex) (interface{}, error) {
_, err := util.Scatter(totalRuns, runtime.GOMAXPROCS(0), func(offset int, entries int, mu *sync.RWMutex) (any, error) {
for i := 0; i < entries; i++ {
mu.Lock()
val++
Expand All @@ -101,7 +101,7 @@ func TestMutex(t *testing.T) {
func TestError(t *testing.T) {
totalRuns := 1024
val := 0
_, err := util.Scatter(totalRuns, runtime.GOMAXPROCS(0), func(offset int, entries int, mu *sync.RWMutex) (interface{}, error) {
_, err := util.Scatter(totalRuns, runtime.GOMAXPROCS(0), func(offset int, entries int, mu *sync.RWMutex) (any, error) {
for i := 0; i < entries; i++ {
mu.Lock()
val++
Expand Down

0 comments on commit ddeb0b4

Please sign in to comment.