Skip to content

Commit 17086ce

Browse files
Merge pull request #51 from MariusVanDerWijden/ci_v3
.github: setup ci
2 parents b3e1f99 + 06b41f4 commit 17086ce

File tree

5 files changed

+84
-45
lines changed

5 files changed

+84
-45
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ name: node-crawler workflow
44
on:
55
push:
66
branches:
7-
- master
7+
- main
88
tags:
99
- '**'
1010
pull_request:
1111
branches:
12-
- master
12+
- main
1313
workflow_dispatch:
1414

1515
jobs:
@@ -26,7 +26,7 @@ jobs:
2626
- name: Lint
2727
run: ./bin/golangci-lint run --config .golangci.yml
2828
- name: Vet
29-
run: go vet
29+
run: go vet ./...
3030

3131
test:
3232
runs-on: ubuntu-latest

.golangci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This file configures github.com/golangci/golangci-lint.
2+
3+
run:
4+
timeout: 20m
5+
tests: true
6+
# default is true. Enables skipping of directories:
7+
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
8+
skip-dirs-use-default: true
9+
10+
linters:
11+
disable-all: true
12+
enable:
13+
- goconst
14+
- goimports
15+
- gosimple
16+
- govet
17+
- ineffassign
18+
- misspell
19+
- unconvert
20+
- typecheck
21+
# this repo contains a few copied files from go-ethereum,
22+
# and some of them have unused fields/functions
23+
#- unused
24+
- staticcheck
25+
- bidichk
26+
- durationcheck
27+
- exportloopref
28+
- whitespace
29+
30+
# - structcheck # lots of false positives
31+
# - errcheck #lot of false positives
32+
# - contextcheck
33+
# - errchkjson # lots of false positives
34+
# - errorlint # this check crashes
35+
# - exhaustive # silly check
36+
# - makezero # false positives
37+
# - nilerr # several intentional
38+
39+
linters-settings:
40+
gofmt:
41+
simplify: true
42+
goconst:
43+
min-len: 3 # minimum length of string constant
44+
min-occurrences: 6 # minimum number of occurrences

cmd/crawler/api.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ func transferNewNodes(crawlerDB, nodeDB *sql.DB) error {
8787
// they are normally recoverable, and a lot of the time, it's
8888
// because the database is locked by the crawler.
8989
return fmt.Errorf("error starting transaction to read nodes: %w", err)
90-
9190
}
9291
defer crawlerDBTx.Rollback()
9392

pkg/crawler/crawl.go

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -175,52 +175,49 @@ func (c *crawler) runIterator(done chan<- enode.Iterator, it enode.Iterator) {
175175

176176
func (c *crawler) getClientInfoLoop() {
177177
defer func() { c.Done() }()
178-
for {
179-
select {
180-
case n, ok := <-c.reqCh:
181-
if !ok {
182-
return
183-
}
178+
for n := range c.reqCh {
179+
if n == nil {
180+
return
181+
}
184182

185-
var tooManyPeers bool
186-
var scoreInc int
183+
var tooManyPeers bool
184+
var scoreInc int
187185

188-
info, err := getClientInfo(c.genesis, c.networkID, c.nodeURL, n)
189-
if err != nil {
190-
log.Warn("GetClientInfo failed", "error", err, "nodeID", n.ID())
191-
if strings.Contains(err.Error(), "too many peers") {
192-
tooManyPeers = true
193-
}
194-
} else {
195-
scoreInc = 10
186+
info, err := getClientInfo(c.genesis, c.networkID, c.nodeURL, n)
187+
if err != nil {
188+
log.Warn("GetClientInfo failed", "error", err, "nodeID", n.ID())
189+
if strings.Contains(err.Error(), "too many peers") {
190+
tooManyPeers = true
196191
}
192+
} else {
193+
scoreInc = 10
194+
}
197195

198-
if info != nil {
199-
log.Info(
200-
"Updating node info",
201-
"client_type", info.ClientType,
202-
"version", info.SoftwareVersion,
203-
"network_id", info.NetworkID,
204-
"caps", info.Capabilities,
205-
"fork_id", info.ForkID,
206-
"height", info.Blockheight,
207-
"td", info.TotalDifficulty,
208-
"head", info.HeadHash,
209-
)
210-
}
196+
if info != nil {
197+
log.Info(
198+
"Updating node info",
199+
"client_type", info.ClientType,
200+
"version", info.SoftwareVersion,
201+
"network_id", info.NetworkID,
202+
"caps", info.Capabilities,
203+
"fork_id", info.ForkID,
204+
"height", info.Blockheight,
205+
"td", info.TotalDifficulty,
206+
"head", info.HeadHash,
207+
)
208+
}
211209

212-
c.Lock()
213-
node := c.output[n.ID()]
214-
node.N = n
215-
node.Seq = n.Seq()
216-
if info != nil {
217-
node.Info = info
218-
}
219-
node.TooManyPeers = tooManyPeers
220-
node.Score += scoreInc
221-
c.output[n.ID()] = node
222-
c.Unlock()
210+
c.Lock()
211+
node := c.output[n.ID()]
212+
node.N = n
213+
node.Seq = n.Seq()
214+
if info != nil {
215+
node.Info = info
223216
}
217+
node.TooManyPeers = tooManyPeers
218+
node.Score += scoreInc
219+
c.output[n.ID()] = node
220+
c.Unlock()
224221
}
225222
}
226223

pkg/vparser/vparser_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
)
77

88
func TestParseVersionString(t *testing.T) {
9-
109
type ParseTestCase struct {
1110
name string
1211
args string

0 commit comments

Comments
 (0)