@@ -249,13 +249,21 @@ export class PeerDiscovery {
249
249
}
250
250
251
251
// Run a discv5 subnet query to try to discover new peers
252
- if ( subnetsToDiscoverPeers . length > 0 || cachedENRsToDial . size < peersToConnect ) {
252
+ const shouldRunFindRandomNodeQuery = subnetsToDiscoverPeers . length > 0 || cachedENRsToDial . size < peersToConnect ;
253
+ if ( shouldRunFindRandomNodeQuery ) {
253
254
void this . runFindRandomNodeQuery ( ) ;
254
255
}
256
+
257
+ this . logger . debug ( "Discover peers outcome" , {
258
+ peersToConnect,
259
+ peersAvailableToDial : cachedENRsToDial . size ,
260
+ subnetsToDiscover : subnetsToDiscoverPeers . length ,
261
+ shouldRunFindRandomNodeQuery,
262
+ } ) ;
255
263
}
256
264
257
265
/**
258
- * Request to find peers. First, looked at cached peers in peerStore
266
+ * Request discv5 to find peers if there is no query in progress
259
267
*/
260
268
private async runFindRandomNodeQuery ( ) : Promise < void > {
261
269
// Delay the 1st query after starting discv5
@@ -305,6 +313,7 @@ export class PeerDiscovery {
305
313
const attnets = zeroAttnets ;
306
314
const syncnets = zeroSyncnets ;
307
315
const status = this . handleDiscoveredPeer ( id , multiaddrs [ 0 ] , attnets , syncnets ) ;
316
+ this . logger . debug ( "Discovered peer via libp2p" , { peer : prettyPrintPeerId ( id ) , status} ) ;
308
317
this . metrics ?. discovery . discoveredStatus . inc ( { status} ) ;
309
318
} ;
310
319
@@ -336,6 +345,7 @@ export class PeerDiscovery {
336
345
const syncnets = syncnetsBytes ? deserializeEnrSubnets ( syncnetsBytes , SYNC_COMMITTEE_SUBNET_COUNT ) : zeroSyncnets ;
337
346
338
347
const status = this . handleDiscoveredPeer ( peerId , multiaddrTCP , attnets , syncnets ) ;
348
+ this . logger . debug ( "Discovered peer via discv5" , { peer : prettyPrintPeerId ( peerId ) , status} ) ;
339
349
this . metrics ?. discovery . discoveredStatus . inc ( { status} ) ;
340
350
} ;
341
351
0 commit comments