Skip to content

Commit

Permalink
Update to golangci-lint 1.40.1.
Browse files Browse the repository at this point in the history
Linter `golint` has been deprecated and replaced with `revive`.
  • Loading branch information
jholdstock authored and dnldd committed Jun 26, 2021
1 parent 0857388 commit bc36f6c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Check out source
uses: actions/checkout@v2
- name: Install Linters
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.37.0"
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.40.1"
- name: Build
env:
GO111MODULE: "on"
Expand Down
35 changes: 14 additions & 21 deletions pool/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ var (
}
)

func splitMinerID(id string) (string, string) {
const separator = "/"
split := strings.Split(id, separator)
return split[0], split[1]
}

func setCurrentWork(work string) {
currentWorkMtx.Lock()
currentWork = work
Expand Down Expand Up @@ -420,10 +426,8 @@ func testClientMessageHandling(t *testing.T) {
return false
}
id++
sep := "/"
d1ID := strings.Split(D1ID, sep)
d1 := d1ID[0]
d1Version := d1ID[1]

d1, d1Version := splitMinerID(d1ID)

r = SubscribeRequest(&id, userAgent(d1, d1Version), "mn001")
err = sE.Encode(r)
Expand Down Expand Up @@ -495,9 +499,7 @@ func testClientMessageHandling(t *testing.T) {
}

id++
dr3ID := strings.Split(DR3ID, sep)
dr3 := dr3ID[0]
dr3Version := dr3ID[1]
dr3, dr3Version := splitMinerID(dr3ID)
r = SubscribeRequest(&id, userAgent(dr3, dr3Version), "")
err = sE.Encode(r)
if err != nil {
Expand Down Expand Up @@ -534,9 +536,7 @@ func testClientMessageHandling(t *testing.T) {
}

id++
dcr1ID := strings.Split(DCR1ID, sep)
dcr1 := dcr1ID[0]
dcr1Version := dcr1ID[1]
dcr1, dcr1Version := splitMinerID(dcr1ID)
r = SubscribeRequest(&id, userAgent(dcr1, dcr1Version), "")
err = sE.Encode(r)
if err != nil {
Expand Down Expand Up @@ -573,9 +573,7 @@ func testClientMessageHandling(t *testing.T) {
}

id++
d9ID := strings.Split(D9ID, sep)
d9 := d9ID[0]
d9Version := d9ID[1]
d9, d9Version := splitMinerID(d9ID)
r = SubscribeRequest(&id, userAgent(d9, d9Version), "")
err = sE.Encode(r)
if err != nil {
Expand Down Expand Up @@ -612,9 +610,7 @@ func testClientMessageHandling(t *testing.T) {
}

id++
cpuID := strings.Split(CPUID, sep)
cpu := cpuID[0]
cpuVersion := cpuID[1]
cpu, cpuVersion := splitMinerID(cpuID)
r = SubscribeRequest(&id, userAgent(cpu, cpuVersion), "")
err = sE.Encode(r)
if err != nil {
Expand Down Expand Up @@ -1472,10 +1468,7 @@ func testClientTimeRolledWork(t *testing.T) {
// Ensure a CPU client receives a valid non-error response when
// a valid subscribe request is sent.
id++
sep := "/"
cpuID := strings.Split(CPUID, sep)
cpu := cpuID[0]
cpuVersion := cpuID[1]
cpu, cpuVersion := splitMinerID(cpuID)
r = SubscribeRequest(&id, userAgent(cpu, cpuVersion), "")
err = sE.Encode(r)
if err != nil {
Expand Down Expand Up @@ -1579,7 +1572,7 @@ func testClientUpgrades(t *testing.T) {
}

minerIdx := 0
idPair := minerIDs[DR3ID]
idPair := minerIDs[dr3ID]

// Trigger a client upgrade.
atomic.StoreInt64(&client.submissions, 50)
Expand Down
4 changes: 2 additions & 2 deletions pool/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ func NewStratumError(code uint32, err error) *StratumError {
}
}

// MashalJSON marshals the stratum error into valid JSON.
// MarshalJSON marshals the stratum error into valid JSON.
func (s *StratumError) MarshalJSON() ([]byte, error) {
return json.Marshal([]interface{}{s.Code, s.Message, s.Traceback})
}

// MashalJSON unmarshals the provided JSON bytes into a stratum error.
// UnmarshalJSON unmarshals the provided JSON bytes into a stratum error.
func (s *StratumError) UnmarshalJSON(p []byte) error {
var tmp []interface{}
if err := json.Unmarshal(p, &tmp); err != nil {
Expand Down
24 changes: 12 additions & 12 deletions pool/miner_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ var (
// These miner ids represent the expected identifications returned by
// supported miners in their mining.subscribe requests.

CPUID = "cpuminer/1.0.0"
DCR1ID = "cgminer/4.10.0"
D9ID = "sgminer/4.4.2"
DR3ID = "cgminer/4.9.0"
D1ID = "whatsminer/d1-v1.0"
NHID = "NiceHash/1.0.0"
cpuID = "cpuminer/1.0.0"
dcr1ID = "cgminer/4.10.0"
d9ID = "sgminer/4.4.2"
dr3ID = "cgminer/4.9.0"
d1ID = "whatsminer/d1-v1.0"
nhID = "NiceHash/1.0.0"
)

// minerIDPair represents miner subscription identification pairing
Expand All @@ -45,12 +45,12 @@ func newMinerIDPair(id string, miners ...string) *minerIDPair {
// generateMinerIDs creates the miner id pairings for all supported miners.
func generateMinerIDs() map[string]*minerIDPair {
ids := make(map[string]*minerIDPair)
cpu := newMinerIDPair(CPUID, CPU)
obelisk := newMinerIDPair(DCR1ID, ObeliskDCR1)
innosilicon := newMinerIDPair(D9ID, InnosiliconD9)
antminer := newMinerIDPair(DR3ID, AntminerDR3, AntminerDR5)
whatsminer := newMinerIDPair(D1ID, WhatsminerD1)
nicehash := newMinerIDPair(NHID, NiceHashValidator)
cpu := newMinerIDPair(cpuID, CPU)
obelisk := newMinerIDPair(dcr1ID, ObeliskDCR1)
innosilicon := newMinerIDPair(d9ID, InnosiliconD9)
antminer := newMinerIDPair(dr3ID, AntminerDR3, AntminerDR5)
whatsminer := newMinerIDPair(d1ID, WhatsminerD1)
nicehash := newMinerIDPair(nhID, NiceHashValidator)

ids[cpu.id] = cpu
ids[obelisk.id] = obelisk
Expand Down
2 changes: 1 addition & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fi
golangci-lint run --disable-all --deadline=10m \
--out-format=$OUT_FORMAT \
--enable=gofmt \
--enable=golint \
--enable=revive \
--enable=vet \
--enable=gosimple \
--enable=unconvert \
Expand Down

0 comments on commit bc36f6c

Please sign in to comment.