@@ -96,7 +96,7 @@ belowTarget
96
96
belowTarget enableAction inboundPeers =
97
97
belowTargetBigLedgerPeers enableAction
98
98
<> belowTargetLocal inboundPeers
99
- <> belowTargetOther
99
+ <> belowTargetOther inboundPeers
100
100
101
101
102
102
-- | For locally configured root peers we have the explicit target that comes from local
@@ -200,6 +200,7 @@ belowTargetLocal inboundPeers
200
200
, let potentialToPromote =
201
201
-- These are local peers that are cold but not ready.
202
202
localRootPeersSet
203
+ Set. \\ unreachablePeers
203
204
Set. \\ localEstablishedPeers
204
205
Set. \\ KnownPeers. availableToConnect knownPeers
205
206
, not (Set. null potentialToPromote)
@@ -239,7 +240,9 @@ belowTargetOther
239
240
, Ord peeraddr
240
241
, HasCallStack
241
242
)
242
- => PeerSelectionActions
243
+ => Map peeraddr PeerSharing
244
+ -- ^ Inbound peers that have negotiated a duplex connection
245
+ -> PeerSelectionActions
243
246
extraState
244
247
extraFlags
245
248
extraPeers
@@ -256,7 +259,7 @@ belowTargetOther
256
259
peeraddr
257
260
peerconn
258
261
m
259
- belowTargetOther actions@ PeerSelectionActions {
262
+ belowTargetOther inboundPeers actions@ PeerSelectionActions {
260
263
extraPeersAPI = PublicExtraPeersAPI {
261
264
memberExtraPeers,
262
265
extraPeersToSet
@@ -283,7 +286,7 @@ belowTargetOther actions@PeerSelectionActions {
283
286
-- not cold and our invariant is that they are always in the connect set.
284
287
-- We can also subtract the in progress ones since they are also already
285
288
-- in the connect set and we cannot pick them again.
286
- , numAvailableToConnect - numFollowBackPeers - numEstablishedPeers - numConnectInProgress > 0
289
+ , numAvailableToConnect - numUnreachablePeers - numEstablishedPeers - numConnectInProgress > 0
287
290
= Guarded Nothing $ do
288
291
-- The availableToPromote here is non-empty due to the second guard.
289
292
-- The known peers map restricted to the connect set is the same size as
@@ -295,7 +298,7 @@ belowTargetOther actions@PeerSelectionActions {
295
298
--
296
299
let availableToPromote :: Set peeraddr
297
300
availableToPromote = availableToConnect
298
- Set. \\ followBackPeers
301
+ Set. \\ unreachablePeers
299
302
Set. \\ EstablishedPeers. toSet establishedPeers
300
303
Set. \\ inProgressPromoteCold
301
304
numPeersToPromote = targetNumberOfEstablishedPeers
@@ -327,11 +330,15 @@ belowTargetOther actions@PeerSelectionActions {
327
330
| otherwise
328
331
= GuardedSkip Nothing
329
332
where
330
- numFollowBackPeers = Set. size followBackPeers
333
+ numUnreachablePeers = Set. size unreachablePeers
331
334
332
- followBackPeers = Map. keysSet
333
- $ Map. filter (\ (LocalRootConfig {followBack}) -> followBack)
334
- $ LocalRootPeers. toMap localRootPeers
335
+ isUnreachablePeer addr (LocalRootConfig {followBack}) =
336
+ followBack && not (Map. member addr inboundPeers)
337
+
338
+ unreachablePeers =
339
+ Map. keysSet
340
+ $ Map. filterWithKey isUnreachablePeer
341
+ $ LocalRootPeers. toMap localRootPeers
335
342
336
343
PeerSelectionView {
337
344
viewKnownBigLedgerPeers = (bigLedgerPeersSet, _),
0 commit comments