Skip to content

Commit 63ca9a4

Browse files
committed
Merge branch 'peers_monitor_log_fix' into grim
2 parents 3ff3efb + e2a32ae commit 63ca9a4

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

servers/src/grin/seed.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,11 @@ fn monitor_peers(
268268
{
269269
new_peers.push(hp.addr);
270270
}
271+
let healthy_count = new_peers.len();
272+
271273
// always check min 32 (max 96, if there are no healthy) random unknown peers received from peer list request.
272274
let req_unk_count = cmp::max(
273-
max_peer_attempts / 2 - new_peers.len() + max_peer_attempts / 4,
275+
max_peer_attempts / 2 - healthy_count + max_peer_attempts / 4,
274276
max_peer_attempts / 4,
275277
);
276278
for upa in unknown
@@ -280,15 +282,8 @@ fn monitor_peers(
280282
{
281283
new_peers.push(*upa);
282284
}
283-
debug!(
284-
"monitor_peers: check {} healthy, {} unknown, {} defuncts",
285-
cmp::min(
286-
new_peers.len() as i32,
287-
((new_peers.len() - req_unk_count) as i32).abs()
288-
),
289-
cmp::min(new_peers.len(), req_unk_count),
290-
max_peer_attempts - new_peers.len()
291-
);
285+
let unk_count = new_peers.len() - healthy_count;
286+
292287
// check min 32 (max 128, if there are no healthy and unknown) random defunct peers no more often than 1 hour per peer.
293288
for dp in defuncts
294289
.iter()
@@ -301,6 +296,12 @@ fn monitor_peers(
301296
{
302297
new_peers.push(dp.addr);
303298
}
299+
let defuncts_count = new_peers.len() - unk_count - healthy_count;
300+
301+
debug!(
302+
"monitor_peers: check {} healthy, {} unknown, {} defuncts",
303+
healthy_count, unk_count, defuncts_count
304+
);
304305

305306
// If the peer db is stale or mostly defunct, include seeds as recovery candidates.
306307
if !enough_outbound {

0 commit comments

Comments
 (0)