@@ -37,6 +37,9 @@ import (
37
37
38
38
var (
39
39
BucketKeyBzzPrivateKey BucketKey = "bzzprivkey"
40
+
41
+ // PropertyBootnode is a property string for NodeConfig, representing that a node is a bootnode
42
+ PropertyBootnode = "bootnode"
40
43
)
41
44
42
45
// NodeIDs returns NodeIDs for all nodes in the network.
@@ -83,10 +86,11 @@ func AddNodeWithMsgEvents(enable bool) AddNodeOption {
83
86
}
84
87
}
85
88
86
- // AddNodeAsBootNode toggles whether the node will be configured as a bootnode
87
- func AddNodeAsBootNode (enable bool ) AddNodeOption {
89
+ // AddNodeWithProperty specifies a property that this node should hold
90
+ // in the running services. (e.g. "bootnode", etc)
91
+ func AddNodeWithProperty (propertyName string ) AddNodeOption {
88
92
return func (o * adapters.NodeConfig ) {
89
- o .BootNode = enable
93
+ o .Properties = append ( o . Properties , propertyName )
90
94
}
91
95
}
92
96
@@ -122,7 +126,13 @@ func (s *Simulation) AddNode(opts ...AddNodeOption) (id enode.ID, err error) {
122
126
123
127
enodeParams := & network.EnodeParams {
124
128
PrivateKey : bzzPrivateKey ,
125
- Bootnode : conf .BootNode ,
129
+ }
130
+
131
+ // Check for any properties relevant to the creation of the Enode Record
132
+ for _ , property := range conf .Properties {
133
+ if property == PropertyBootnode {
134
+ enodeParams .Bootnode = true
135
+ }
126
136
}
127
137
128
138
record , err := network .NewEnodeRecord (enodeParams )
@@ -153,9 +163,9 @@ func (s *Simulation) AddNodes(count int, opts ...AddNodeOption) (ids []enode.ID,
153
163
return ids , nil
154
164
}
155
165
156
- // AddBootNode creates a bootnode using AddNode(opts) and appends it to Simulation.bootNodes
157
- func (s * Simulation ) AddBootNode (opts ... AddNodeOption ) (id enode.ID , err error ) {
158
- opts = append (opts , AddNodeAsBootNode ( true ))
166
+ // AddBootnode creates a bootnode using AddNode(opts) and appends it to Simulation.bootNodes
167
+ func (s * Simulation ) AddBootnode (opts ... AddNodeOption ) (id enode.ID , err error ) {
168
+ opts = append (opts , AddNodeWithProperty ( PropertyBootnode ))
159
169
id , err = s .AddNode (opts ... )
160
170
if err != nil {
161
171
return id , err
@@ -164,19 +174,7 @@ func (s *Simulation) AddBootNode(opts ...AddNodeOption) (id enode.ID, err error)
164
174
return id , nil
165
175
}
166
176
167
- // AddBootNodes creates count number of bootnodes using AddNodes(count, opts)
168
- // and appends them to Simulation.bootNodes
169
- func (s * Simulation ) AddBootNodes (count int , opts ... AddNodeOption ) (ids []enode.ID , err error ) {
170
- opts = append (opts , AddNodeAsBootNode (true ))
171
- ids , err = s .AddNodes (count , opts ... )
172
- if err != nil {
173
- return nil , err
174
- }
175
-
176
- return ids , err
177
- }
178
-
179
- // AddNodesAndConnectFull is a helpper method that combines
177
+ // AddNodesAndConnectFull is a helper method that combines
180
178
// AddNodes and ConnectNodesFull. Only new nodes will be connected.
181
179
func (s * Simulation ) AddNodesAndConnectFull (count int , opts ... AddNodeOption ) (ids []enode.ID , err error ) {
182
180
if count < 2 {
@@ -237,7 +235,7 @@ func (s *Simulation) AddNodesAndConnectRing(count int, opts ...AddNodeOption) (i
237
235
return ids , nil
238
236
}
239
237
240
- // AddNodesAndConnectStar is a helpper method that combines
238
+ // AddNodesAndConnectStar is a helper method that combines
241
239
// AddNodes and ConnectNodesStar.
242
240
func (s * Simulation ) AddNodesAndConnectStar (count int , opts ... AddNodeOption ) (ids []enode.ID , err error ) {
243
241
if count < 2 {
@@ -254,11 +252,11 @@ func (s *Simulation) AddNodesAndConnectStar(count int, opts ...AddNodeOption) (i
254
252
return ids , nil
255
253
}
256
254
257
- // AddNodesAndConnectToBootNode is a helper method that combines
258
- // AddNodes, AddBootNode and ConnectNodesStar, where the center node is a new bootnode.
255
+ // AddNodesAndConnectToBootnode is a helper method that combines
256
+ // AddNodes, AddBootnode and ConnectNodesStar, where the center node is a new bootnode.
259
257
// The count parameter excludes the bootnode.
260
- func (s * Simulation ) AddNodesAndConnectToBootNode (count int , opts ... AddNodeOption ) (ids []enode.ID , bootNodeID enode.ID , err error ) {
261
- bootNodeID , err = s .AddBootNode (opts ... )
258
+ func (s * Simulation ) AddNodesAndConnectToBootnode (count int , opts ... AddNodeOption ) (ids []enode.ID , bootNodeID enode.ID , err error ) {
259
+ bootNodeID , err = s .AddBootnode (opts ... )
262
260
if err != nil {
263
261
return nil , bootNodeID , err
264
262
}
0 commit comments