Skip to content

Commit

Permalink
Merge pull request #51 from MariusVanDerWijden/ci_v3
Browse files Browse the repository at this point in the history
.github: setup ci
  • Loading branch information
MariusVanDerWijden committed Sep 22, 2023
2 parents b3e1f99 + 06b41f4 commit 17086ce
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ name: node-crawler workflow
on:
push:
branches:
- master
- main
tags:
- '**'
pull_request:
branches:
- master
- main
workflow_dispatch:

jobs:
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Lint
run: ./bin/golangci-lint run --config .golangci.yml
- name: Vet
run: go vet
run: go vet ./...

test:
runs-on: ubuntu-latest
Expand Down
44 changes: 44 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This file configures github.com/golangci/golangci-lint.

run:
timeout: 20m
tests: true
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

linters:
disable-all: true
enable:
- goconst
- goimports
- gosimple
- govet
- ineffassign
- misspell
- unconvert
- typecheck
# this repo contains a few copied files from go-ethereum,
# and some of them have unused fields/functions
#- unused
- staticcheck
- bidichk
- durationcheck
- exportloopref
- whitespace

# - structcheck # lots of false positives
# - errcheck #lot of false positives
# - contextcheck
# - errchkjson # lots of false positives
# - errorlint # this check crashes
# - exhaustive # silly check
# - makezero # false positives
# - nilerr # several intentional

linters-settings:
gofmt:
simplify: true
goconst:
min-len: 3 # minimum length of string constant
min-occurrences: 6 # minimum number of occurrences
1 change: 0 additions & 1 deletion cmd/crawler/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func transferNewNodes(crawlerDB, nodeDB *sql.DB) error {
// they are normally recoverable, and a lot of the time, it's
// because the database is locked by the crawler.
return fmt.Errorf("error starting transaction to read nodes: %w", err)

}
defer crawlerDBTx.Rollback()

Expand Down
77 changes: 37 additions & 40 deletions pkg/crawler/crawl.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,52 +175,49 @@ func (c *crawler) runIterator(done chan<- enode.Iterator, it enode.Iterator) {

func (c *crawler) getClientInfoLoop() {
defer func() { c.Done() }()
for {
select {
case n, ok := <-c.reqCh:
if !ok {
return
}
for n := range c.reqCh {
if n == nil {
return
}

var tooManyPeers bool
var scoreInc int
var tooManyPeers bool
var scoreInc int

info, err := getClientInfo(c.genesis, c.networkID, c.nodeURL, n)
if err != nil {
log.Warn("GetClientInfo failed", "error", err, "nodeID", n.ID())
if strings.Contains(err.Error(), "too many peers") {
tooManyPeers = true
}
} else {
scoreInc = 10
info, err := getClientInfo(c.genesis, c.networkID, c.nodeURL, n)
if err != nil {
log.Warn("GetClientInfo failed", "error", err, "nodeID", n.ID())
if strings.Contains(err.Error(), "too many peers") {
tooManyPeers = true
}
} else {
scoreInc = 10
}

if info != nil {
log.Info(
"Updating node info",
"client_type", info.ClientType,
"version", info.SoftwareVersion,
"network_id", info.NetworkID,
"caps", info.Capabilities,
"fork_id", info.ForkID,
"height", info.Blockheight,
"td", info.TotalDifficulty,
"head", info.HeadHash,
)
}
if info != nil {
log.Info(
"Updating node info",
"client_type", info.ClientType,
"version", info.SoftwareVersion,
"network_id", info.NetworkID,
"caps", info.Capabilities,
"fork_id", info.ForkID,
"height", info.Blockheight,
"td", info.TotalDifficulty,
"head", info.HeadHash,
)
}

c.Lock()
node := c.output[n.ID()]
node.N = n
node.Seq = n.Seq()
if info != nil {
node.Info = info
}
node.TooManyPeers = tooManyPeers
node.Score += scoreInc
c.output[n.ID()] = node
c.Unlock()
c.Lock()
node := c.output[n.ID()]
node.N = n
node.Seq = n.Seq()
if info != nil {
node.Info = info
}
node.TooManyPeers = tooManyPeers
node.Score += scoreInc
c.output[n.ID()] = node
c.Unlock()
}
}

Expand Down
1 change: 0 additions & 1 deletion pkg/vparser/vparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
)

func TestParseVersionString(t *testing.T) {

type ParseTestCase struct {
name string
args string
Expand Down

0 comments on commit 17086ce

Please sign in to comment.