async fn poll_validator_indices<T: SlotClock + 'static, E: EthSpec>(
    duties_service: &DutiesService<T, E>,
) {
    let _timer =
        metrics::start_timer_vec(&metrics::DUTIES_SERVICE_TIMES, &[metrics::UPDATE_INDICES]);

    let log = duties_service.context.log();
    for pubkey in duties_service.validator_store.voting_pubkeys() {
        // This is on its own line to avoid some weirdness with locks and if statements.
        let is_known = duties_service.indices.read().contains_key(&pubkey);

        if !is_known {
            // Query the remote BN to resolve a pubkey to a validator index.
            let download_result = duties_service
                .beacon_nodes
                .first_success(duties_service.require_synced, |beacon_node| async move {
                    beacon_node
                        .get_beacon_states_validator_id(
                            StateId::Head,
                            &ValidatorId::PublicKey(pubkey),
                        )
                        .await
                })
                .await;

            match download_result {
                Ok(Some(response)) => {
                    info!(
                        log,
                        "Validator exists in beacon chain";
                        "pubkey" => ?pubkey,
                        "validator_index" => response.data.index
                    );
                    duties_service
                        .indices
                        .write()
                        .insert(pubkey, response.data.index);
                }
                // This is not necessarily an error, it just means the validator is not yet known to
                // the beacon chain.
                Ok(None) => {
                    debug!(
                        log,
                        "Validator without index";
                        "pubkey" => ?pubkey
                    )
                }
                // Don't exit early on an error, keep attempting to resolve other indices.
                Err(e) => {
                    error!(
                        log,
                        "Failed to resolve pubkey to index";
                        "error" => %e,
                        "pubkey" => ?pubkey,
                    )
                }
            }
        }
    }
}
/// Iterate through all the voting pubkeys in the `ValidatorStore` and attempt to learn any unknown
/// validator indices.
Iterate through all the voting pubkeys in the `ValidatorStore` and attempt to learn any unknown
validator indices.
Iterate through all the voting pubkeys in the ` ValidatorStore ` and attempt to learn any unknown validator indices .
async fn poll_validator_indices<T: SlotClock + 'static, E: EthSpec>(
    duties_service: &DutiesService<T, E>,
) {
    let _timer =
        metrics::start_timer_vec(&metrics::DUTIES_SERVICE_TIMES, &[metrics::UPDATE_INDICES]);
    let log = duties_service.context.log();
    for pubkey in duties_service.validator_store.voting_pubkeys() {
        // This is on its own line to avoid some weirdness with locks and if statements.
        let is_known = duties_service.indices.read().contains_key(&pubkey);
        if !is_known {
            // Query the remote BN to resolve a pubkey to a validator index.
            let download_result = duties_service
                .beacon_nodes
                .first_success(duties_service.require_synced, |beacon_node| async move {
                    beacon_node
                        .get_beacon_states_validator_id(
                            StateId::Head,
                            &ValidatorId::PublicKey(pubkey),
                        )
                        .await
                })
                .await;
            match download_result {
                Ok(Some(response)) => {
                    info!(
                        log,
                        "Validator exists in beacon chain";
                        "pubkey" => ?pubkey,
                        "validator_index" => response.data.index
                    );
                    duties_service
                        .indices
                        .write()
                        .insert(pubkey, response.data.index);
                }
                // This is not necessarily an error, it just means the validator is not yet known to
                // the beacon chain.
                Ok(None) => {
                    debug!(
                        log,
                        "Validator without index";
                        "pubkey" => ?pubkey
                    )
                }
                // Don't exit early on an error, keep attempting to resolve other indices.
                Err(e) => {
                    error!(
                        log,
                        "Failed to resolve pubkey to index";
                        "error" => %e,
                        "pubkey" => ?pubkey,
                    )
                }
            }
        }
    }
}
async fn poll_validator_indices < T : SlotClock + ' static , E : EthSpec > ( duties_service : & DutiesService < T , E > , ) { let _timer = metrics :: start_timer_vec ( & metrics :: DUTIES_SERVICE_TIMES , & [ metrics :: UPDATE_INDICES ] ) ; let log = duties_service . context . log ( ) ; for pubkey in duties_service . validator_store . voting_pubkeys ( ) { // This is on its own line to avoid some weirdness with locks and if statements. let is_known = duties_service . indices . read ( ) . contains_key ( & pubkey ) ; if ! is_known { // Query the remote BN to resolve a pubkey to a validator index. let download_result = duties_service . beacon_nodes . first_success ( duties_service . require_synced , | beacon_node | async move { beacon_node . get_beacon_states_validator_id ( StateId :: Head , & ValidatorId :: PublicKey ( pubkey ) , ) . await } ) . await ; match download_result { Ok ( Some ( response ) ) => { info ! ( log " " " " pubkey " " response data index ) ; duties_service . indices . write ( ) . insert ( pubkey , response . data . index ) ; } // This is not necessarily an error, it just means the validator is not yet known to // the beacon chain. Ok ( None ) => { debug ! ( log " " " " pubkey ) } // Don't exit early on an error, keep attempting to resolve other indices. Err ( e ) => { error ! ( log " " " " e " " pubkey ) } } } } }
Iterate through all the voting pubkeys in the `ValidatorStore` and attempt to learn any unknown
validator indices.
Iterate through all the voting pubkeys in the ` ValidatorStore ` and attempt to learn any unknown validator indices .
duties_service
&DutiesService<T, E>