diff --git a/.gitignore b/.gitignore index 6d8ed26..12418f5 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ yarn.lock node_modules logs/ + +golangci-lint +build \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index fa9697a..e7b2fda 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -34,49 +34,32 @@ linters: # - stylecheck linters-settings: - gocritic: - # Which checks should be enabled; can't be combined with 'disabled-checks'; - # See https://go-critic.github.io/overview#checks-overview - # To check which checks are enabled run `GL_DEBUG=gocritic ./build/bin/golangci-lint run` - # By default list of stable checks is used. - enabled-checks: - # - ruleguard - # - defaultCaseOrder - - # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty + gocritic: # see https://golangci-lint.run/usage/linters/#gocritic and https://go-critic.github.io/overview#checks-overview + enabled-tags: + - performance + - diagnostic + - style disabled-checks: - - regexpMust - - appendAssign - # - hugeParam - rangeValCopy - exitAfterDefer - elseif - dupBranchBody - assignOp - singleCaseSwitch - - unlambda - captLocal - commentFormatting - ifElseChain + - sprintfQuotedString + - commentedOutCode + - preferFprint + + # style tag - importShadow + - emptyStringTest - paramTypeCombine - - builtinShadow - - typeUnparen + - unnamedResult - # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks. - # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". - enabled-tags: - - performance - - diagnostic - - opinionated - disabled-tags: - - experimental settings: - # ruleguard: - # rules: "rules.go" - hugeParam: - # size in bytes that makes the warning trigger (default 80) - sizeThreshold: 1000 rangeExprCopy: # size in bytes that makes the warning trigger (default 512) sizeThreshold: 512 @@ -96,7 +79,7 @@ linters-settings: min-len: 2 min-occurrences: 2 gofmt: - auto-fix: false + simplify: false issues: exclude-rules: diff --git a/build/bin/golangci-lint b/build/bin/golangci-lint index 3f251c5..ce66cb9 100755 Binary files a/build/bin/golangci-lint and b/build/bin/golangci-lint differ diff --git a/internal/erigon_node/bodies_download.go b/internal/erigon_node/bodies_download.go index 1cc9f35..2bbb70b 100644 --- a/internal/erigon_node/bodies_download.go +++ b/internal/erigon_node/bodies_download.go @@ -10,10 +10,6 @@ import ( ) func (c *NodeClient) BodiesDownload(ctx context.Context, w http.ResponseWriter) { - /*snapshot := btree.NewG(16, func(a, b SnapshotItem) bool { - return a.Id < b.Id - })*/ - var tick int64 sendEvery := time.NewTicker(1000 * time.Millisecond) defer sendEvery.Stop() diff --git a/internal/erigon_node/erigon_client.go b/internal/erigon_node/erigon_client.go index 8789344..a06eafe 100644 --- a/internal/erigon_node/erigon_client.go +++ b/internal/erigon_node/erigon_client.go @@ -13,7 +13,7 @@ import ( var _ Client = &NodeClient{} type NodeClient struct { - sync.Mutex + lock sync.Mutex requestId uint64 requestChannel chan *NodeRequest nodeId string @@ -27,10 +27,10 @@ func NewClient(nodeId string, requestChannel chan *NodeRequest) Client { } func (c *NodeClient) nextRequestId() string { - c.Lock() + c.lock.Lock() id := c.requestId c.requestId++ - c.Unlock() + c.lock.Unlock() return strconv.FormatUint(id, 10) } diff --git a/internal/erigon_node/headers_download.go b/internal/erigon_node/headers_download.go index f35ea74..422cf92 100644 --- a/internal/erigon_node/headers_download.go +++ b/internal/erigon_node/headers_download.go @@ -10,10 +10,6 @@ import ( ) func (c *NodeClient) HeadersDownload(ctx context.Context, w http.ResponseWriter) { - /* - snapshot := btree.NewG(16, func(a, b SnapshotItem) bool { - return a.Id < b.Id - })*/ var tick int64 sendEvery := time.NewTicker(1000 * time.Millisecond) defer sendEvery.Stop() diff --git a/internal/erigon_node/remote_db.go b/internal/erigon_node/remote_db.go index 0b40732..b555366 100644 --- a/internal/erigon_node/remote_db.go +++ b/internal/erigon_node/remote_db.go @@ -74,9 +74,9 @@ func (r *results) UnmarshalJSON(json []byte) (err error) { switch json[i] { case byte('"'): - len, value := tostr(json[i:]) + length, value := tostr(json[i:]) - i += len + i += length if result[ri], err = base64.URLEncoding.DecodeString(value); err != nil { return err @@ -161,7 +161,6 @@ func (rc *RemoteCursor) findFullDbPath(ctx context.Context, db string) (string, if err != nil { return "", err } - // fmt.Println("lines: ", lines) var dbPath string diff --git a/internal/sessions/node.go b/internal/sessions/node.go index bbd843c..f36fa04 100644 --- a/internal/sessions/node.go +++ b/internal/sessions/node.go @@ -28,7 +28,7 @@ type NodeInfo struct { // NodeSession corresponds to one Erigon node connected via "erigon support" bridge to an operator type NodeSession struct { - sync.Mutex + lock sync.Mutex Connected bool RemoteAddr string Client erigon_node.Client @@ -39,15 +39,15 @@ type NodeSession struct { } func (ns *NodeSession) Connect(remoteAddr string) { - ns.Lock() - defer ns.Unlock() + ns.lock.Lock() + defer ns.lock.Unlock() ns.Connected = true ns.RemoteAddr = remoteAddr } func (ns *NodeSession) Disconnect() { - ns.Lock() - defer ns.Unlock() + ns.lock.Lock() + defer ns.lock.Unlock() ns.Connected = false }