fn storage_query_discovery_set(
    libra_db: Arc<dyn DbReader>,
    req_msg: QueryDiscoverySetRequest,
) -> Result<(QueryDiscoverySetRequest, Box<QueryDiscoverySetResponse>)> {
    // TODO(philiphayes): how to deal with partial epoch change proof?
    let (latest_li, epoch_change_proof, accumulator_proof) = libra_db
        .get_state_proof(req_msg.known_version)
        .with_context(|| {
            format!(
                "error getting state proof from storage: request version: {}",
                req_msg.known_version,
            )
        })?;

    // Only return the discovery set account if the requestor is not in the most
    // recent epoch.
    let account_state = if epoch_change_proof.ledger_info_with_sigs.is_empty() {
        None
    } else {
        Some(
            libra_db.get_account_state_with_proof(
                account_config::validator_set_address(), req_msg.known_version, latest_li.ledger_info().version()
            ).with_context(|| {
                format!("error getting discovery account state with proof from storage: request version: {}, ledger info version: {}",
                    req_msg.known_version, latest_li.ledger_info().version(),
                )
            })?
        )
    };

    let res_msg = Box::new(QueryDiscoverySetResponse {
        latest_li,
        epoch_change_proof,
        accumulator_proof,
        account_state,
    });

    Ok((req_msg, res_msg))
}
/// Query our own storage for the latest discovery set and epoch change proof.
Query our own storage for the latest discovery set and epoch change proof.
Query our own storage for the latest discovery set and epoch change proof .
fn storage_query_discovery_set(
    libra_db: Arc<dyn DbReader>,
    req_msg: QueryDiscoverySetRequest,
) -> Result<(QueryDiscoverySetRequest, Box<QueryDiscoverySetResponse>)> {
    // TODO(philiphayes): how to deal with partial epoch change proof?
    let (latest_li, epoch_change_proof, accumulator_proof) = libra_db
        .get_state_proof(req_msg.known_version)
        .with_context(|| {
            format!(
                "error getting state proof from storage: request version: {}",
                req_msg.known_version,
            )
        })?;
    // Only return the discovery set account if the requestor is not in the most
    // recent epoch.
    let account_state = if epoch_change_proof.ledger_info_with_sigs.is_empty() {
        None
    } else {
        Some(
            libra_db.get_account_state_with_proof(
                account_config::validator_set_address(), req_msg.known_version, latest_li.ledger_info().version()
            ).with_context(|| {
                format!("error getting discovery account state with proof from storage: request version: {}, ledger info version: {}",
                    req_msg.known_version, latest_li.ledger_info().version(),
                )
            })?
        )
    };
    let res_msg = Box::new(QueryDiscoverySetResponse {
        latest_li,
        epoch_change_proof,
        accumulator_proof,
        account_state,
    });
    Ok((req_msg, res_msg))
}
fn storage_query_discovery_set ( libra_db : Arc < dyn DbReader > , req_msg : QueryDiscoverySetRequest , ) -> Result < ( QueryDiscoverySetRequest , Box < QueryDiscoverySetResponse > ) > { // TODO(philiphayes): how to deal with partial epoch change proof? let ( latest_li , epoch_change_proof , accumulator_proof ) = libra_db . get_state_proof ( req_msg . known_version ) . with_context ( | | { format ! ( " " req_msg known_version ) } ) ? ; // Only return the discovery set account if the requestor is not in the most // recent epoch. let account_state = if epoch_change_proof . ledger_info_with_sigs . is_empty ( ) { None } else { Some ( libra_db . get_account_state_with_proof ( account_config :: validator_set_address ( ) , req_msg . known_version , latest_li . ledger_info ( ) . version ( ) ) . with_context ( | | { format ! ( " " req_msg known_version latest_li ledger_info ( ) version ( ) ) } ) ? ) } ; let res_msg = Box :: new ( QueryDiscoverySetResponse { latest_li , epoch_change_proof , accumulator_proof , account_state , } ) ; Ok ( ( req_msg , res_msg ) ) }
Query our own storage for the latest discovery set and epoch change proof.
Query our own storage for the latest discovery set and epoch change proof .
libra_db
Arc<dyn DbReader>
req_msg
QueryDiscoverySetRequest
libra_db
Arc<dyn DbReader>
req_msg
QueryDiscoverySetRequest