@@ -37,6 +37,9 @@ import (
3737
3838var (
3939 BucketKeyBzzPrivateKey BucketKey = "bzzprivkey"
40+
41+ // PropertyBootnode is a property string for NodeConfig, representing that a node is a bootnode
42+ PropertyBootnode = "bootnode"
4043)
4144
4245// NodeIDs returns NodeIDs for all nodes in the network.
@@ -83,10 +86,11 @@ func AddNodeWithMsgEvents(enable bool) AddNodeOption {
8386 }
8487}
8588
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 {
8892 return func (o * adapters.NodeConfig ) {
89- o .BootNode = enable
93+ o .Properties = append ( o . Properties , propertyName )
9094 }
9195}
9296
@@ -122,7 +126,13 @@ func (s *Simulation) AddNode(opts ...AddNodeOption) (id enode.ID, err error) {
122126
123127 enodeParams := & network.EnodeParams {
124128 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+ }
126136 }
127137
128138 record , err := network .NewEnodeRecord (enodeParams )
@@ -153,9 +163,9 @@ func (s *Simulation) AddNodes(count int, opts ...AddNodeOption) (ids []enode.ID,
153163 return ids , nil
154164}
155165
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 ))
159169 id , err = s .AddNode (opts ... )
160170 if err != nil {
161171 return id , err
@@ -164,19 +174,7 @@ func (s *Simulation) AddBootNode(opts ...AddNodeOption) (id enode.ID, err error)
164174 return id , nil
165175}
166176
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
180178// AddNodes and ConnectNodesFull. Only new nodes will be connected.
181179func (s * Simulation ) AddNodesAndConnectFull (count int , opts ... AddNodeOption ) (ids []enode.ID , err error ) {
182180 if count < 2 {
@@ -237,7 +235,7 @@ func (s *Simulation) AddNodesAndConnectRing(count int, opts ...AddNodeOption) (i
237235 return ids , nil
238236}
239237
240- // AddNodesAndConnectStar is a helpper method that combines
238+ // AddNodesAndConnectStar is a helper method that combines
241239// AddNodes and ConnectNodesStar.
242240func (s * Simulation ) AddNodesAndConnectStar (count int , opts ... AddNodeOption ) (ids []enode.ID , err error ) {
243241 if count < 2 {
@@ -254,11 +252,11 @@ func (s *Simulation) AddNodesAndConnectStar(count int, opts ...AddNodeOption) (i
254252 return ids , nil
255253}
256254
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.
259257// 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 ... )
262260 if err != nil {
263261 return nil , bootNodeID , err
264262 }
0 commit comments