Skip to content

Commit fe03b76

Browse files
frncmxzelig
authored andcommitted
A few minor code inspection fixes (#18393)
* swarm/network: fix code inspection problems - typos - redundant import alias * p2p/simulations: fix code inspection problems - typos - unused function parameters - redundant import alias - code style issue: snake case * swarm/network: fix unused method parameters inspections
1 parent 072c95f commit fe03b76

14 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎p2p/simulations/adapters/exec.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import (
4646

4747
func init() {
4848
// Register a reexec function to start a simulation node when the current binary is
49-
// executed as "p2p-node" (rather than whataver the main() function would normally do).
49+
// executed as "p2p-node" (rather than whatever the main() function would normally do).
5050
reexec.Register("p2p-node", execP2PNode)
5151
}
5252

‎p2p/simulations/adapters/inproc.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (s *SimAdapter) Dial(dest *enode.Node) (conn net.Conn, err error) {
130130
return nil, err
131131
}
132132
// this is simulated 'listening'
133-
// asynchronously call the dialed destintion node's p2p server
133+
// asynchronously call the dialed destination node's p2p server
134134
// to set up connection on the 'listening' side
135135
go srv.SetupConn(pipe1, 0, nil)
136136
return pipe2, nil

‎p2p/simulations/connect_test.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
)
2626

2727
func newTestNetwork(t *testing.T, nodeCount int) (*Network, []enode.ID) {
28+
t.Helper()
2829
adapter := adapters.NewSimAdapter(adapters.Services{
2930
"noopwoop": func(ctx *adapters.ServiceContext) (node.Service, error) {
3031
return NewNoopService(nil), nil

‎p2p/simulations/http_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"github.com/ethereum/go-ethereum/p2p/enode"
3636
"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
3737
"github.com/ethereum/go-ethereum/rpc"
38-
colorable "github.com/mattn/go-colorable"
38+
"github.com/mattn/go-colorable"
3939
)
4040

4141
var (
@@ -294,6 +294,7 @@ var testServices = adapters.Services{
294294
}
295295

296296
func testHTTPServer(t *testing.T) (*Network, *httptest.Server) {
297+
t.Helper()
297298
adapter := adapters.NewSimAdapter(testServices)
298299
network := NewNetwork(adapter, &NetworkConfig{
299300
DefaultService: "test",

‎p2p/simulations/mocker_test.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

1717
// Package simulations simulates p2p networks.
18-
// A mokcer simulates starting and stopping real nodes in a network.
18+
// A mocker simulates starting and stopping real nodes in a network.
1919
package simulations
2020

2121
import (
@@ -135,13 +135,13 @@ func TestMocker(t *testing.T) {
135135
wg.Wait()
136136

137137
//check there are nodeCount number of nodes in the network
138-
nodes_info, err := client.GetNodes()
138+
nodesInfo, err := client.GetNodes()
139139
if err != nil {
140140
t.Fatalf("Could not get nodes list: %s", err)
141141
}
142142

143-
if len(nodes_info) != nodeCount {
144-
t.Fatalf("Expected %d number of nodes, got: %d", nodeCount, len(nodes_info))
143+
if len(nodesInfo) != nodeCount {
144+
t.Fatalf("Expected %d number of nodes, got: %d", nodeCount, len(nodesInfo))
145145
}
146146

147147
//stop the mocker
@@ -160,12 +160,12 @@ func TestMocker(t *testing.T) {
160160
}
161161

162162
//now the number of nodes in the network should be zero
163-
nodes_info, err = client.GetNodes()
163+
nodesInfo, err = client.GetNodes()
164164
if err != nil {
165165
t.Fatalf("Could not get nodes list: %s", err)
166166
}
167167

168-
if len(nodes_info) != 0 {
169-
t.Fatalf("Expected empty list of nodes, got: %d", len(nodes_info))
168+
if len(nodesInfo) != 0 {
169+
t.Fatalf("Expected empty list of nodes, got: %d", len(nodesInfo))
170170
}
171171
}

‎p2p/simulations/network.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ func (net *Network) getConn(oneID, otherID enode.ID) *Conn {
518518
return net.Conns[i]
519519
}
520520

521-
// InitConn(one, other) retrieves the connectiton model for the connection between
521+
// InitConn(one, other) retrieves the connection model for the connection between
522522
// peers one and other, or creates a new one if it does not exist
523523
// the order of nodes does not matter, i.e., Conn(i,j) == Conn(j, i)
524524
// it checks if the connection is already up, and if the nodes are running
@@ -564,8 +564,8 @@ func (net *Network) Shutdown() {
564564
close(net.quitc)
565565
}
566566

567-
//Reset resets all network properties:
568-
//emtpies the nodes and the connection list
567+
// Reset resets all network properties:
568+
// empties the nodes and the connection list
569569
func (net *Network) Reset() {
570570
net.lock.Lock()
571571
defer net.lock.Unlock()

‎swarm/network/simulation/bucket.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import "github.com/ethereum/go-ethereum/p2p/enode"
2121
// BucketKey is the type that should be used for keys in simulation buckets.
2222
type BucketKey string
2323

24-
// NodeItem returns an item set in ServiceFunc function for a particualar node.
24+
// NodeItem returns an item set in ServiceFunc function for a particular node.
2525
func (s *Simulation) NodeItem(id enode.ID, key interface{}) (value interface{}, ok bool) {
2626
s.mu.Lock()
2727
defer s.mu.Unlock()

‎swarm/network/simulation/bucket_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
2525
)
2626

27-
// TestServiceBucket tests all bucket functionalities using subtests.
27+
// TestServiceBucket tests all bucket functionality using subtests.
2828
// It constructs a simulation of two nodes by adding items to their buckets
2929
// in ServiceFunc constructor, then by SetNodeItem. Testing UpNodesItems
3030
// is done by stopping one node and validating availability of its items.

‎swarm/network/simulation/example_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
// Every node can have a Kademlia associated using the node bucket under
2727
// BucketKeyKademlia key. This allows to use WaitTillHealthy to block until
28-
// all nodes have the their Kadmlias healthy.
28+
// all nodes have the their Kademlias healthy.
2929
func ExampleSimulation_WaitTillHealthy() {
3030

3131
log.Error("temporarily disabled as simulations.WaitTillHealthy cannot be trusted")

‎swarm/network/simulation/kademlia.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
)
2929

3030
// BucketKeyKademlia is the key to be used for storing the kademlia
31-
// instance for particuar node, usually inside the ServiceFunc function.
31+
// instance for particular node, usually inside the ServiceFunc function.
3232
var BucketKeyKademlia BucketKey = "kademlia"
3333

3434
// WaitTillHealthy is blocking until the health of all kademlias is true.

0 commit comments

Comments
 (0)