@@ -128,7 +128,7 @@ func newPriorityPool(ns *nodestate.NodeStateMachine, setup *serverSetup, clock m
128
128
} else {
129
129
ns .SetStateSub (node , nodestate.Flags {}, pp .setup .activeFlag .Or (pp .setup .inactiveFlag ), 0 )
130
130
if n , _ := pp .ns .GetField (node , pp .setup .queueField ).(* ppNodeInfo ); n != nil {
131
- pp .disconnectedNode (n )
131
+ pp .disconnectNode (n )
132
132
}
133
133
ns .SetFieldSub (node , pp .setup .capacityField , nil )
134
134
ns .SetFieldSub (node , pp .setup .queueField , nil )
@@ -137,10 +137,10 @@ func newPriorityPool(ns *nodestate.NodeStateMachine, setup *serverSetup, clock m
137
137
ns .SubscribeState (pp .setup .activeFlag .Or (pp .setup .inactiveFlag ), func (node * enode.Node , oldState , newState nodestate.Flags ) {
138
138
if c , _ := pp .ns .GetField (node , pp .setup .queueField ).(* ppNodeInfo ); c != nil {
139
139
if oldState .IsEmpty () {
140
- pp .connectedNode (c )
140
+ pp .connectNode (c )
141
141
}
142
142
if newState .IsEmpty () {
143
- pp .disconnectedNode (c )
143
+ pp .disconnectNode (c )
144
144
}
145
145
}
146
146
})
@@ -233,6 +233,14 @@ func (pp *priorityPool) Active() (uint64, uint64) {
233
233
return pp .activeCount , pp .activeCap
234
234
}
235
235
236
+ // Inactive returns the number of currently inactive nodes
237
+ func (pp * priorityPool ) Inactive () int {
238
+ pp .lock .Lock ()
239
+ defer pp .lock .Unlock ()
240
+
241
+ return pp .inactiveQueue .Size ()
242
+ }
243
+
236
244
// Limits returns the maximum allowed number and total capacity of active nodes
237
245
func (pp * priorityPool ) Limits () (uint64 , uint64 ) {
238
246
pp .lock .Lock ()
@@ -285,9 +293,9 @@ func (pp *priorityPool) inactivePriority(p *ppNodeInfo) int64 {
285
293
return p .nodePriority .priority (pp .minCap )
286
294
}
287
295
288
- // connectedNode is called when a new node has been added to the pool (inactiveFlag set)
296
+ // connectNode is called when a new node has been added to the pool (inactiveFlag set)
289
297
// Note: this function should run inside a NodeStateMachine operation
290
- func (pp * priorityPool ) connectedNode (c * ppNodeInfo ) {
298
+ func (pp * priorityPool ) connectNode (c * ppNodeInfo ) {
291
299
pp .lock .Lock ()
292
300
pp .activeQueue .Refresh ()
293
301
if c .connected {
@@ -301,10 +309,10 @@ func (pp *priorityPool) connectedNode(c *ppNodeInfo) {
301
309
pp .updateFlags (updates )
302
310
}
303
311
304
- // disconnectedNode is called when a node has been removed from the pool (both inactiveFlag
312
+ // disconnectNode is called when a node has been removed from the pool (both inactiveFlag
305
313
// and activeFlag reset)
306
314
// Note: this function should run inside a NodeStateMachine operation
307
- func (pp * priorityPool ) disconnectedNode (c * ppNodeInfo ) {
315
+ func (pp * priorityPool ) disconnectNode (c * ppNodeInfo ) {
308
316
pp .lock .Lock ()
309
317
pp .activeQueue .Refresh ()
310
318
if ! c .connected {
0 commit comments