mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
all: simplify nested complexity and if blocks ending with a return statement (#21854)
Changes: Simplify nested complexity If an if blocks ends with a return statement then remove the else nesting. Most of the changes has also been reported in golint https://goreportcard.com/report/github.com/ethereum/go-ethereum#golint # Conflicts: # cmd/utils/flags.go # console/bridge.go # crypto/bls12381/g2.go # les/benchmark.go # les/lespay/server/balance.go # les/lespay/server/balance_tracker.go # les/lespay/server/prioritypool.go # les/odr_requests.go # les/serverpool.go # les/serverpool_test.go # p2p/nodestate/nodestate_test.go # trie/committer.go
This commit is contained in:
parent
e461541dfb
commit
86dd1f91dd
@ -751,12 +751,10 @@ func DefaultConfigDir() string {
|
||||
appdata := os.Getenv("APPDATA")
|
||||
if appdata != "" {
|
||||
return filepath.Join(appdata, "Signer")
|
||||
} else {
|
||||
return filepath.Join(home, "AppData", "Roaming", "Signer")
|
||||
}
|
||||
} else {
|
||||
return filepath.Join(home, ".clef")
|
||||
return filepath.Join(home, "AppData", "Roaming", "Signer")
|
||||
}
|
||||
return filepath.Join(home, ".clef")
|
||||
}
|
||||
// As we cannot guess a stable location, return empty and handle later
|
||||
return ""
|
||||
|
@ -368,9 +368,8 @@ func (hc *HeaderChain) GetAncestor(hash common.Hash, number, ancestor uint64, ma
|
||||
// in this case it is cheaper to just read the header
|
||||
if header := hc.GetHeader(hash, number); header != nil {
|
||||
return header.ParentHash, number - 1
|
||||
} else {
|
||||
return common.Hash{}, 0
|
||||
}
|
||||
return common.Hash{}, 0
|
||||
}
|
||||
for ancestor != 0 {
|
||||
h, err := rawdb.ReadCanonicalHash(hc.chainDb, number)
|
||||
|
@ -267,9 +267,8 @@ func (g *G1) Add(r, p1, p2 *PointG1) *PointG1 {
|
||||
if t[1].equal(t[3]) {
|
||||
if t[0].equal(t[2]) {
|
||||
return g.Double(r, p1)
|
||||
} else {
|
||||
return r.Zero()
|
||||
}
|
||||
return r.Zero()
|
||||
}
|
||||
sub(t[1], t[1], t[3])
|
||||
double(t[4], t[1])
|
||||
|
@ -288,9 +288,8 @@ func (g *G2) Add(r, p1, p2 *PointG2) *PointG2 {
|
||||
if t[1].equal(t[3]) {
|
||||
if t[0].equal(t[2]) {
|
||||
return g.Double(r, p1)
|
||||
} else { //nolint:golint
|
||||
return r.Zero()
|
||||
}
|
||||
return r.Zero()
|
||||
}
|
||||
g.f.sub(t[1], t[1], t[3])
|
||||
g.f.double(t[4], t[1])
|
||||
|
@ -220,9 +220,8 @@ func (n *autodisc) String() string {
|
||||
defer n.mu.Unlock()
|
||||
if n.found == nil {
|
||||
return n.what
|
||||
} else {
|
||||
return n.found.String()
|
||||
}
|
||||
return n.found.String()
|
||||
}
|
||||
|
||||
// wait blocks until auto-discovery has been performed.
|
||||
|
@ -454,9 +454,8 @@ func (net *Network) getNodeIDs(excludeIDs []enode.ID) []enode.ID {
|
||||
if len(excludeIDs) > 0 {
|
||||
// Return the difference of nodeIDs and excludeIDs
|
||||
return filterIDs(nodeIDs, excludeIDs)
|
||||
} else {
|
||||
return nodeIDs
|
||||
}
|
||||
return nodeIDs
|
||||
}
|
||||
|
||||
// GetNodes returns the existing nodes.
|
||||
@ -472,9 +471,8 @@ func (net *Network) getNodes(excludeIDs []enode.ID) []*Node {
|
||||
if len(excludeIDs) > 0 {
|
||||
nodeIDs := net.getNodeIDs(excludeIDs)
|
||||
return net.getNodesByID(nodeIDs)
|
||||
} else {
|
||||
return net.Nodes
|
||||
}
|
||||
return net.Nodes
|
||||
}
|
||||
|
||||
// GetNodesByID returns existing nodes with the given enode.IDs.
|
||||
@ -1098,7 +1096,6 @@ func (net *Network) executeNodeEvent(e *Event) error {
|
||||
func (net *Network) executeConnEvent(e *Event) error {
|
||||
if e.Conn.Up {
|
||||
return net.Connect(e.Conn.One, e.Conn.Other)
|
||||
} else {
|
||||
return net.Disconnect(e.Conn.One, e.Conn.Other)
|
||||
}
|
||||
return net.Disconnect(e.Conn.One, e.Conn.Other)
|
||||
}
|
||||
|
@ -41,9 +41,8 @@ func (e *testEncoder) EncodeRLP(w io.Writer) error {
|
||||
}
|
||||
if e.err != nil {
|
||||
return e.err
|
||||
} else {
|
||||
w.Write([]byte{0, 1, 0, 1, 0, 1, 0, 1, 0, 1})
|
||||
}
|
||||
w.Write([]byte{0, 1, 0, 1, 0, 1, 0, 1, 0, 1})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -405,9 +405,8 @@ func (c *Client) Notify(ctx context.Context, method string, args ...interface{})
|
||||
|
||||
if c.isHTTP {
|
||||
return c.sendHTTP(ctx, op, msg)
|
||||
} else {
|
||||
return c.send(ctx, op, msg)
|
||||
}
|
||||
return c.send(ctx, op, msg)
|
||||
}
|
||||
|
||||
// EthSubscribe registers a subscripion under the "eth" namespace.
|
||||
|
Loading…
Reference in New Issue
Block a user