Skip to content

Ohttp-relay selection should still be randomized even when ohttp-keys is hard coded in the config. #1384

@benalleng

Description

@benalleng

This code skips ohttp_relay selection when ohttp_keys are hard coded and default chooses the 0 index relay of the possible relays.

pub(crate) async fn unwrap_ohttp_keys_or_else_fetch(
config: &Config,
directory: Option<url::Url>,
relay_manager: Arc<Mutex<RelayManager>>,
) -> Result<ValidatedOhttpKeys> {
if let Some(ohttp_keys) = config.v2()?.ohttp_keys.clone() {
println!("Using OHTTP Keys from config");
return Ok(ValidatedOhttpKeys {
ohttp_keys,
relay_url: config.v2()?.ohttp_relays[0].clone(),
});
} else {
println!("Bootstrapping private network transport over Oblivious HTTP");
let fetched_keys = fetch_ohttp_keys(config, directory, relay_manager).await?;
Ok(fetched_keys)
}
}

While skipping reaching out to the relay when you already have an ohttp-key may make sense, and even be desirable for initial key grab, as it has already been set, whether through a cache or otherwise. We should still utilize a randomized relay selection for followup connections to update the state of a payjoin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions