build: use golangci-lint (#20295)

* build: use golangci-lint

This changes build/ci.go to download and run golangci-lint instead
of gometalinter.

* core/state: fix unnecessary conversion

* p2p/simulations: fix lock copying (found by go vet)

* signer/core: fix unnecessary conversions

* crypto/ecies: remove unused function cmpPublic

* core/rawdb: remove unused function print

* core/state: remove unused function xTestFuzzCutter

* core/vm: disable TestWriteExpectedValues in a different way

* core/forkid: remove unused function checksum

* les: remove unused type proofsData

* cmd/utils: remove unused functions prefixedNames, prefixFor

* crypto/bn256: run goimports

* p2p/nat: fix goimports lint issue

* cmd/clef: avoid using unkeyed struct fields

* les: cancel context in testRequest

* rlp: delete unreachable code

* core: gofmt

* internal/build: simplify DownloadFile for Go 1.11 compatibility

* build: remove go test --short flag

* .travis.yml: disable build cache

* whisper/whisperv6: fix ineffectual assignment in TestWhisperIdentityManagement

* .golangci.yml: enable goconst and ineffassign linters

* build: print message when there are no lint issues

* internal/build: refactor download a bit
This commit is contained in:
Felix Lange
2019-11-18 09:49:18 +01:00
committed by Péter Szilágyi
parent 7c4a4eb58a
commit 689486449d
29 changed files with 352 additions and 314 deletions

View File

@ -119,10 +119,7 @@ func (net *Network) NewNodeWithConfig(conf *adapters.NodeConfig) (*Node, error)
if err != nil {
return nil, err
}
node := &Node{
Node: adapterNode,
Config: conf,
}
node := newNode(adapterNode, conf, false)
log.Trace("Node created", "id", conf.ID)
nodeIndex := len(net.Nodes)
@ -448,7 +445,7 @@ func (net *Network) GetNodeIDs(excludeIDs ...enode.ID) []enode.ID {
}
func (net *Network) getNodeIDs(excludeIDs []enode.ID) []enode.ID {
// Get all curent nodeIDs
// Get all current nodeIDs
nodeIDs := make([]enode.ID, 0, len(net.nodeMap))
for id := range net.nodeMap {
nodeIDs = append(nodeIDs, id)
@ -735,7 +732,16 @@ type Node struct {
// up tracks whether or not the node is running
up bool
upMu sync.RWMutex
upMu *sync.RWMutex
}
func newNode(an adapters.Node, ac *adapters.NodeConfig, up bool) *Node {
return &Node{Node: an, Config: ac, up: up, upMu: new(sync.RWMutex)}
}
func (n *Node) copy() *Node {
configCpy := *n.Config
return newNode(n.Node, &configCpy, n.Up())
}
// Up returns whether the node is currently up (online)
@ -787,22 +793,19 @@ func (n *Node) MarshalJSON() ([]byte, error) {
})
}
// UnmarshalJSON implements json.Unmarshaler interface so that we don't lose
// Node.up status. IMPORTANT: The implementation is incomplete; we lose
// p2p.NodeInfo.
// UnmarshalJSON implements json.Unmarshaler interface so that we don't lose Node.up
// status. IMPORTANT: The implementation is incomplete; we lose p2p.NodeInfo.
func (n *Node) UnmarshalJSON(raw []byte) error {
// TODO: How should we turn back NodeInfo into n.Node?
// Ticket: https://github.com/ethersphere/go-ethereum/issues/1177
node := struct {
var node struct {
Config *adapters.NodeConfig `json:"config,omitempty"`
Up bool `json:"up"`
}{}
}
if err := json.Unmarshal(raw, &node); err != nil {
return err
}
n.SetUp(node.Up)
n.Config = node.Config
*n = *newNode(nil, node.Config, node.Up)
return nil
}
@ -899,7 +902,7 @@ func (net *Network) snapshot(addServices []string, removeServices []string) (*Sn
Nodes: make([]NodeSnapshot, len(net.Nodes)),
}
for i, node := range net.Nodes {
snap.Nodes[i] = NodeSnapshot{Node: *node}
snap.Nodes[i] = NodeSnapshot{Node: *node.copy()}
if !node.Up() {
continue
}