@@ -25,21 +25,8 @@ import (
25
25
26
26
var (
27
27
ErrNodeNotFound = errors .New ("node not found" )
28
- ErrNoPivotNode = errors .New ("no pivot node set" )
29
28
)
30
29
31
- // ConnectToPivotNode connects the node with provided NodeID
32
- // to the pivot node, already set by Network.SetPivotNode method.
33
- // It is useful when constructing a star network topology
34
- // when Network adds and removes nodes dynamically.
35
- func (net * Network ) ConnectToPivotNode (id enode.ID ) (err error ) {
36
- pivot := net .GetPivotNode ()
37
- if pivot == nil {
38
- return ErrNoPivotNode
39
- }
40
- return net .connect (pivot .ID (), id )
41
- }
42
-
43
30
// ConnectToLastNode connects the node with provided NodeID
44
31
// to the last node that is up, and avoiding connection to self.
45
32
// It is useful when constructing a chain network topology
@@ -115,35 +102,23 @@ func (net *Network) ConnectNodesRing(ids []enode.ID) (err error) {
115
102
return net .connect (ids [l - 1 ], ids [0 ])
116
103
}
117
104
118
- // ConnectNodesStar connects all nodes in a star topology
119
- // with the center at provided NodeID.
105
+ // ConnectNodesStar connects all nodes into a star topology
120
106
// If ids argument is nil, all nodes that are up will be connected.
121
- func (net * Network ) ConnectNodesStar (pivot enode.ID , ids [] enode.ID ) (err error ) {
107
+ func (net * Network ) ConnectNodesStar (ids [] enode.ID , center enode.ID ) (err error ) {
122
108
if ids == nil {
123
109
ids = net .getUpNodeIDs ()
124
110
}
125
111
for _ , id := range ids {
126
- if pivot == id {
112
+ if center == id {
127
113
continue
128
114
}
129
- if err := net .connect (pivot , id ); err != nil {
115
+ if err := net .connect (center , id ); err != nil {
130
116
return err
131
117
}
132
118
}
133
119
return nil
134
120
}
135
121
136
- // ConnectNodesStarPivot connects all nodes in a star topology
137
- // with the center at already set pivot node.
138
- // If ids argument is nil, all nodes that are up will be connected.
139
- func (net * Network ) ConnectNodesStarPivot (ids []enode.ID ) (err error ) {
140
- pivot := net .GetPivotNode ()
141
- if pivot == nil {
142
- return ErrNoPivotNode
143
- }
144
- return net .ConnectNodesStar (pivot .ID (), ids )
145
- }
146
-
147
122
// connect connects two nodes but ignores already connected error.
148
123
func (net * Network ) connect (oneID , otherID enode.ID ) error {
149
124
return ignoreAlreadyConnectedErr (net .Connect (oneID , otherID ))
@@ -155,22 +130,3 @@ func ignoreAlreadyConnectedErr(err error) error {
155
130
}
156
131
return err
157
132
}
158
-
159
- // SetPivotNode sets the NodeID of the network's pivot node.
160
- // Pivot node is just a specific node that should be treated
161
- // differently then other nodes in test. SetPivotNode and
162
- // GetPivotNode are just a convenient functions to set and
163
- // retrieve it.
164
- func (net * Network ) SetPivotNode (id enode.ID ) {
165
- net .lock .Lock ()
166
- defer net .lock .Unlock ()
167
- net .pivotNodeID = id
168
- }
169
-
170
- // GetPivotNode returns NodeID of the pivot node set by
171
- // Network.SetPivotNode method.
172
- func (net * Network ) GetPivotNode () (node * Node ) {
173
- net .lock .RLock ()
174
- defer net .lock .RUnlock ()
175
- return net .getNode (net .pivotNodeID )
176
- }
0 commit comments