Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common stuff #27

Merged
merged 6 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ v:
test:
go test ./...

bench:
go test -bench=. -run=Bench ./...

fmt:
gofmt -s -w .
gci write .
gofumpt -w -extra .
go mod tidy

lint:
gofmt -d ./
go vet ./...
Expand Down
4 changes: 2 additions & 2 deletions blocksub/blocksub.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type BlockSub struct {
wsConnectingCond *sync.Cond
}

func NewBlockSub(ctx context.Context, ethNodeHTTPURI string, ethNodeWebsocketURI string) *BlockSub {
func NewBlockSub(ctx context.Context, ethNodeHTTPURI, ethNodeWebsocketURI string) *BlockSub {
ctx, cancel := context.WithCancel(ctx)
sub := &BlockSub{
PollTimeout: 10 * time.Second,
Expand Down Expand Up @@ -242,7 +242,7 @@ func (s *BlockSub) _startWebsocket() (err error) {

// Listen for headers and errors, and reconnect if needed
go func() {
var timer = time.NewTimer(s.SubTimeout)
timer := time.NewTimer(s.SubTimeout)

for {
select {
Expand Down
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func CheckErr(err error) {
}

// GetEnv returns the value of the environment variable named by key, or defaultValue if the environment variable doesn't exist
func GetEnv(key string, defaultValue string) string {
func GetEnv(key, defaultValue string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
Expand Down
3 changes: 1 addition & 2 deletions examples/blocksub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"io"
"os"

"golang.org/x/exp/slog"

"github.com/ethereum/go-ethereum/log"
"github.com/flashbots/go-utils/blocksub"
"golang.org/x/exp/slog"
)

var (
Expand Down
4 changes: 1 addition & 3 deletions examples/httplogger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
"go.uber.org/zap"
)

var (
listenAddr = "localhost:8124"
)
var listenAddr = "localhost:8124"

func HelloHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, World!"))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/stretchr/testify v1.8.4
go.uber.org/atomic v1.11.0
go.uber.org/zap v1.25.0
golang.org/x/crypto v0.17.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
)

Expand All @@ -34,7 +35,6 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.16.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion jsonrpc/mockserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *MockJSONRPCServer) handleHTTPRequest(w http.ResponseWriter, req *http.R
}

func (s *MockJSONRPCServer) IncrementRequestCounter(method string) {
var newCount = 0
newCount := 0
currentCount, ok := s.RequestCounter.Load(method)
if ok {
newCount = currentCount.(int)
Expand Down
Loading
Loading