download_consensus

Function download_consensus 

Source
pub async fn download_consensus(
    microdescriptor: bool,
    endpoints: Option<&[DirPort]>,
    request_timeout: Option<Duration>,
) -> Result<DownloadResult, Error>
Expand description

Downloads the current network consensus.

The consensus is the agreed-upon view of the Tor network, containing information about all known relays. It is signed by a majority of directory authorities.

§Arguments

  • microdescriptor - If true, downloads the microdescriptor consensus (smaller, used by clients). If false, downloads the full consensus.
  • endpoints - Optional list of endpoints to try. If None, uses default directory authorities.
  • request_timeout - Optional timeout for each download attempt.

§Returns

A DownloadResult containing the consensus document.

§Errors

Returns Error::Download if all endpoints fail. Returns Error::DownloadTimeout if all attempts timeout.

§Example

use stem_rs::descriptor::remote::download_consensus;
use std::time::Duration;

// Download microdescriptor consensus (smaller, for clients)
let result = download_consensus(true, None, Some(Duration::from_secs(60))).await?;
println!("Consensus size: {} bytes", result.content.len());