/// Read from the ledger the validator config from the validator set for the specified account
Read from the ledger the validator config from the validator set for the specified account
Read from the ledger the validator config from the validator set for the specified account
fn validator_config(
    validator_account: AccountAddress,
    reader: Arc<dyn DbReader>,
) -> Result<ValidatorConfig, Error> {
    let blob = reader
        .get_latest_account_state(account_config::validator_set_address())
        .map_err(|e| {
            Error::UnexpectedError(format!("ValidatorSet Account issue {}", e.to_string()))
        })?
        .ok_or_else(|| Error::UnexpectedError("ValidatorSet Account not found".into()))?;
    let account_state = AccountState::try_from(&blob)
        .map_err(|e| Error::UnexpectedError(format!("Failed to parse blob: {}", e)))?;
    let validator_set: ValidatorSet = account_state
        .get_validator_set()
        .map_err(|e| Error::UnexpectedError(format!("ValidatorSet issue {}", e.to_string())))?
        .ok_or_else(|| Error::UnexpectedError("ValidatorSet does not exist".into()))?;
    let info = validator_set
        .payload()
        .iter()
        .find(|vi| vi.account_address() == &validator_account)
        .ok_or_else(|| {
            Error::UnexpectedError(format!(
                "Unable to find Validator account {:?}",
                &validator_account
            ))
        })?;
    Ok(info.config().clone())
}
fn validator_config ( validator_account : AccountAddress , reader : Arc < dyn DbReader > , ) -> Result < ValidatorConfig , Error > { let blob = reader . get_latest_account_state ( account_config :: validator_set_address ( ) ) . map_err ( | e | { Error :: UnexpectedError ( format ! ( " " e to_string ( ) ) ) } ) ? . ok_or_else ( | | Error :: UnexpectedError ( " " . into ( ) ) ) ? ; let account_state = AccountState :: try_from ( & blob ) . map_err ( | e | Error :: UnexpectedError ( format ! ( " " e ) ) ) ? ; let validator_set : ValidatorSet = account_state . get_validator_set ( ) . map_err ( | e | Error :: UnexpectedError ( format ! ( " " e to_string ( ) ) ) ) ? . ok_or_else ( | | Error :: UnexpectedError ( " " . into ( ) ) ) ? ; let info = validator_set . payload ( ) . iter ( ) . find ( | vi | vi . account_address ( ) == & validator_account ) . ok_or_else ( | | { Error :: UnexpectedError ( format ! ( " " validator_account ) ) } ) ? ; Ok ( info . config ( ) . clone ( ) ) }
Read from the ledger the validator config from the validator set for the specified account
Read from the ledger the validator config from the validator set for the specified account
validator_account
AccountAddress
reader
Arc<dyn DbReader>