async fn attempt_rebootstrap(
    bootstrap: &mut TableBootstrap,
    attempts: &mut usize,
    routing_table: &RoutingTable,
    socket: &Socket,
    timer: &mut Timer<ScheduledTaskCheck>,
    routers: &HashSet<String>,
    resolved_routers: &mut HashSet<SocketAddr>,
) -> Option<bool> {
    loop {
        // Increment the bootstrap counter
        *attempts += 1;

        log::warn!(
            "Bootstrap attempt {} failed, attempting a rebootstrap",
            *attempts
        );

        // Check if we reached the maximum bootstrap attempts
        if *attempts >= MAX_BOOTSTRAP_ATTEMPTS {
            if routing_table.num_good_nodes() == 0 {
                // Failed to get any nodes in the rebootstrap attempts, shut down
                return None;
            } else {
                return Some(false);
            }
        } else {
            let bootstrap_status = bootstrap
                .start_bootstrap(routing_table.node_id(), socket, timer, routers, resolved_routers)
                .await;

            match bootstrap_status {
                ActionStatus::Ongoing => return Some(true),
                ActionStatus::Completed => {
                    if !should_rebootstrap(routing_table) {
                        return Some(false);
                    }
                }
            }
        }
    }
}
/// Attempt to rebootstrap or shutdown the dht if we have no nodes after rebootstrapping multiple time.
/// Returns None if the DHT is shutting down, Some(true) if the rebootstrap process started,
/// Some(false) if a rebootstrap is not necessary.
Attempt to rebootstrap or shutdown the dht if we have no nodes after rebootstrapping multiple time.
Returns None if the DHT is shutting down, Some(true) if the rebootstrap process started,
Some(false) if a rebootstrap is not necessary.
Attempt to rebootstrap or shutdown the dht if we have no nodes after rebootstrapping multiple time . Returns None if the DHT is shutting down Some ( true ) if the rebootstrap process started Some ( false ) if a rebootstrap is not necessary .
async fn attempt_rebootstrap(
    bootstrap: &mut TableBootstrap,
    attempts: &mut usize,
    routing_table: &RoutingTable,
    socket: &Socket,
    timer: &mut Timer<ScheduledTaskCheck>,
    routers: &HashSet<String>,
    resolved_routers: &mut HashSet<SocketAddr>,
) -> Option<bool> {
    loop {
        // Increment the bootstrap counter
        *attempts += 1;
        log::warn!(
            "Bootstrap attempt {} failed, attempting a rebootstrap",
            *attempts
        );
        // Check if we reached the maximum bootstrap attempts
        if *attempts >= MAX_BOOTSTRAP_ATTEMPTS {
            if routing_table.num_good_nodes() == 0 {
                // Failed to get any nodes in the rebootstrap attempts, shut down
                return None;
            } else {
                return Some(false);
            }
        } else {
            let bootstrap_status = bootstrap
                .start_bootstrap(routing_table.node_id(), socket, timer, routers, resolved_routers)
                .await;
            match bootstrap_status {
                ActionStatus::Ongoing => return Some(true),
                ActionStatus::Completed => {
                    if !should_rebootstrap(routing_table) {
                        return Some(false);
                    }
                }
            }
        }
    }
}
async fn attempt_rebootstrap ( bootstrap : & mut TableBootstrap , attempts : & mut usize , routing_table : & RoutingTable , socket : & Socket , timer : & mut Timer < ScheduledTaskCheck > , routers : & HashSet < String > , resolved_routers : & mut HashSet < SocketAddr > , ) -> Option < bool > { loop { // Increment the bootstrap counter * attempts += 1 ; log :: warn ! ( " " attempts ) ; // Check if we reached the maximum bootstrap attempts if * attempts >= MAX_BOOTSTRAP_ATTEMPTS { if routing_table . num_good_nodes ( ) == 0 { // Failed to get any nodes in the rebootstrap attempts, shut down return None ; } else { return Some ( false ) ; } } else { let bootstrap_status = bootstrap . start_bootstrap ( routing_table . node_id ( ) , socket , timer , routers , resolved_routers ) . await ; match bootstrap_status { ActionStatus :: Ongoing => return Some ( true ) , ActionStatus :: Completed => { if ! should_rebootstrap ( routing_table ) { return Some ( false ) ; } } } } } }
Attempt to rebootstrap or shutdown the dht if we have no nodes after rebootstrapping multiple time.
Attempt to rebootstrap or shutdown the dht if we have no nodes after rebootstrapping multiple time .
bootstrap
&mut TableBootstrap
attempts
&mut usize
routing_table
&RoutingTable
socket
&Socket
timer
&mut Timer<ScheduledTaskCheck>
routers
&HashSet<String>
resolved_routers
&mut HashSet<SocketAddr>
bootstrap
&mut TableBootstrap
attempts
&mut usize
routing_table
&RoutingTable
socket
&Socket
timer
&mut Timer<ScheduledTaskCheck>
routers
&HashSet<String>
resolved_routers
&mut HashSet<SocketAddr>