File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -2502,7 +2502,7 @@ pub fn propagate_gossip_cross_thread<TContentKey: OverlayContentKey>(
25022502) -> usize {
25032503 // Get all connected nodes from overlay routing table
25042504 let kbuckets = kbuckets. read ( ) ;
2505- let all_nodes: Vec < & kbucket:: Node < NodeId , Node > > = kbuckets
2505+ let mut all_nodes: Vec < & kbucket:: Node < NodeId , Node > > = kbuckets
25062506 . buckets_iter ( )
25072507 . flat_map ( |kbucket| {
25082508 kbucket
@@ -2512,6 +2512,24 @@ pub fn propagate_gossip_cross_thread<TContentKey: OverlayContentKey>(
25122512 } )
25132513 . collect ( ) ;
25142514
2515+ if all_nodes. is_empty ( ) {
2516+ warn ! ( "No connected nodes, using disconnected nodes for gossip." ) ;
2517+ all_nodes = kbuckets
2518+ . buckets_iter ( )
2519+ . flat_map ( |kbucket| {
2520+ kbucket
2521+ . iter ( )
2522+ . collect :: < Vec < & kbucket:: Node < NodeId , Node > > > ( )
2523+ } )
2524+ . collect ( ) ;
2525+ }
2526+
2527+ if all_nodes. is_empty ( ) {
2528+ // If there are no nodes whatsoever in the routing table the gossip cannot proceed.
2529+ warn ! ( "No nodes in routing table, gossip cannot proceed." ) ;
2530+ return 0 ;
2531+ }
2532+
25152533 // HashMap to temporarily store all interested ENRs and the content.
25162534 // Key is base64 string of node's ENR.
25172535 let mut enrs_and_content: HashMap < String , Vec < ( RawContentKey , Vec < u8 > ) > > = HashMap :: new ( ) ;
You can’t perform that action at this time.
0 commit comments