async fn send_bootstrap_requests(
        &mut self,
        nodes: &[NodeHandle],
        target_id: NodeId,
        table: &mut RoutingTable,
        socket: &Socket,
        timer: &mut Timer<ScheduledTaskCheck>,
    ) -> bool {
        let mut messages_sent = 0;

        for node in nodes {
            // Generate a transaction id
            let trans_id = self.id_generator.generate();
            let find_node_msg = Message {
                transaction_id: trans_id.as_ref().to_vec(),
                body: MessageBody::Request(Request::FindNode(FindNodeRequest {
                    id: table.node_id(),
                    target: target_id,
                    want: None,
                })),
            }
            .encode();

            // Add a timeout for the node
            let timeout = timer.schedule_in(
                BOOTSTRAP_NODE_TIMEOUT,
                ScheduledTaskCheck::BootstrapTimeout(trans_id),
            );

            // Send the message to the node
            if let Err(error) = socket.send(&find_node_msg, node.addr).await {
                log::error!("Could not send a bootstrap message: {}", error);
                continue;
            }

            // Mark that we requested from the node
            if let Some(node) = table.find_node_mut(node) {
                node.local_request();
            }

            // Create an entry for the timeout in the map
            self.active_messages.insert(trans_id, timeout);

            messages_sent += 1;
        }

        messages_sent > 0
    }
// If this returns `false` it means the request wasn't sent to any node (either because there
// were no nodes or because all the sends failed). We should proceed to the next bucket in that
// case.
If this returns `false` it means the request wasn't sent to any node (either because there
were no nodes or because all the sends failed). We should proceed to the next bucket in that
case.
If this returns ` false ` it means the request wasn ' t sent to any node ( either because there were no nodes or because all the sends failed ) . We should proceed to the next bucket in that case .
async fn send_bootstrap_requests(
        &mut self,
        nodes: &[NodeHandle],
        target_id: NodeId,
        table: &mut RoutingTable,
        socket: &Socket,
        timer: &mut Timer<ScheduledTaskCheck>,
    ) -> bool {
        let mut messages_sent = 0;
        for node in nodes {
            // Generate a transaction id
            let trans_id = self.id_generator.generate();
            let find_node_msg = Message {
                transaction_id: trans_id.as_ref().to_vec(),
                body: MessageBody::Request(Request::FindNode(FindNodeRequest {
                    id: table.node_id(),
                    target: target_id,
                    want: None,
                })),
            }
            .encode();
            // Add a timeout for the node
            let timeout = timer.schedule_in(
                BOOTSTRAP_NODE_TIMEOUT,
                ScheduledTaskCheck::BootstrapTimeout(trans_id),
            );
            // Send the message to the node
            if let Err(error) = socket.send(&find_node_msg, node.addr).await {
                log::error!("Could not send a bootstrap message: {}", error);
                continue;
            }
            // Mark that we requested from the node
            if let Some(node) = table.find_node_mut(node) {
                node.local_request();
            }
            // Create an entry for the timeout in the map
            self.active_messages.insert(trans_id, timeout);
            messages_sent += 1;
        }
        messages_sent > 0
    }
async fn send_bootstrap_requests ( & mut self , nodes : & [ NodeHandle ] , target_id : NodeId , table : & mut RoutingTable , socket : & Socket , timer : & mut Timer < ScheduledTaskCheck > , ) -> bool { let mut messages_sent = 0 ; for node in nodes { // Generate a transaction id let trans_id = self . id_generator . generate ( ) ; let find_node_msg = Message { transaction_id : trans_id . as_ref ( ) . to_vec ( ) , body : MessageBody :: Request ( Request :: FindNode ( FindNodeRequest { id : table . node_id ( ) , target : target_id , want : None , } ) ) , } . encode ( ) ; // Add a timeout for the node let timeout = timer . schedule_in ( BOOTSTRAP_NODE_TIMEOUT , ScheduledTaskCheck :: BootstrapTimeout ( trans_id ) , ) ; // Send the message to the node if let Err ( error ) = socket . send ( & find_node_msg , node . addr ) . await { log :: error ! ( " " error ) ; continue ; } // Mark that we requested from the node if let Some ( node ) = table . find_node_mut ( node ) { node . local_request ( ) ; } // Create an entry for the timeout in the map self . active_messages . insert ( trans_id , timeout ) ; messages_sent += 1 ; } messages_sent > 0 }
If this returns `false` it means the request wasn't sent to any node (either because there
were no nodes or because all the sends failed).
If this returns ` false ` it means the request wasn ' t sent to any node ( either because there were no nodes or because all the sends failed ) .
&mut self
nodes
&[NodeHandle]
target_id
NodeId
table
&mut RoutingTable
socket
&Socket
timer
&mut Timer<ScheduledTaskCheck>
&mut self
nodes
&[NodeHandle]
target_id
NodeId
table
&mut RoutingTable
socket
&Socket
timer
&mut Timer<ScheduledTaskCheck>