pub(crate) async fn is_bonded_validator(
        self,
        validator: PublicKey,
        era_id: EraId,
        latest_state_root_hash: Option<Digest>,
        protocol_version: ProtocolVersion,
    ) -> Result<bool, GetEraValidatorsError>
    where
        REv: From<ContractRuntimeRequest> + From<StorageRequest> + From<ChainspecLoaderRequest>,
    {
        // try just reading the era validators first
        let maybe_era_validators = self.get_era_validators(era_id).await;
        let maybe_is_currently_bonded =
            maybe_era_validators.map(|validators| validators.contains_key(&validator));

        match maybe_is_currently_bonded {
            // if we know whether the validator is bonded, just return that
            Some(is_bonded) => Ok(is_bonded),
            // if not, try checking future eras with the latest state root hash
            None => match latest_state_root_hash {
                // no root hash later than initial -> we just assume the validator is not bonded
                None => Ok(false),
                // otherwise, check with contract runtime
                Some(state_root_hash) => self
                    .make_request(
                        |responder| ContractRuntimeRequest::IsBonded {
                            state_root_hash,
                            era_id,
                            protocol_version,
                            public_key: validator,
                            responder,
                        },
                        QueueKind::Regular,
                    )
                    .await
                    .or_else(|error| {
                        // Promote this error to a non-error case.
                        // It's not an error that we can't find the era that was requested.
                        if error.is_era_validators_missing() {
                            Ok(false)
                        } else {
                            Err(error)
                        }
                    }),
            },
        }
    }
/// Checks whether the given validator is bonded in the given era.
Checks whether the given validator is bonded in the given era.
Checks whether the given validator is bonded in the given era .
pub(crate) async fn is_bonded_validator(
        self,
        validator: PublicKey,
        era_id: EraId,
        latest_state_root_hash: Option<Digest>,
        protocol_version: ProtocolVersion,
    ) -> Result<bool, GetEraValidatorsError>
    where
        REv: From<ContractRuntimeRequest> + From<StorageRequest> + From<ChainspecLoaderRequest>,
    {
        // try just reading the era validators first
        let maybe_era_validators = self.get_era_validators(era_id).await;
        let maybe_is_currently_bonded =
            maybe_era_validators.map(|validators| validators.contains_key(&validator));
        match maybe_is_currently_bonded {
            // if we know whether the validator is bonded, just return that
            Some(is_bonded) => Ok(is_bonded),
            // if not, try checking future eras with the latest state root hash
            None => match latest_state_root_hash {
                // no root hash later than initial -> we just assume the validator is not bonded
                None => Ok(false),
                // otherwise, check with contract runtime
                Some(state_root_hash) => self
                    .make_request(
                        |responder| ContractRuntimeRequest::IsBonded {
                            state_root_hash,
                            era_id,
                            protocol_version,
                            public_key: validator,
                            responder,
                        },
                        QueueKind::Regular,
                    )
                    .await
                    .or_else(|error| {
                        // Promote this error to a non-error case.
                        // It's not an error that we can't find the era that was requested.
                        if error.is_era_validators_missing() {
                            Ok(false)
                        } else {
                            Err(error)
                        }
                    }),
            },
        }
    }
pub ( crate ) async fn is_bonded_validator ( self , validator : PublicKey , era_id : EraId , latest_state_root_hash : Option < Digest > , protocol_version : ProtocolVersion , ) -> Result < bool , GetEraValidatorsError > where REv : From < ContractRuntimeRequest > + From < StorageRequest > + From < ChainspecLoaderRequest > , { // try just reading the era validators first let maybe_era_validators = self . get_era_validators ( era_id ) . await ; let maybe_is_currently_bonded = maybe_era_validators . map ( | validators | validators . contains_key ( & validator ) ) ; match maybe_is_currently_bonded { // if we know whether the validator is bonded, just return that Some ( is_bonded ) => Ok ( is_bonded ) , // if not, try checking future eras with the latest state root hash None => match latest_state_root_hash { // no root hash later than initial -> we just assume the validator is not bonded None => Ok ( false ) , // otherwise, check with contract runtime Some ( state_root_hash ) => self . make_request ( | responder | ContractRuntimeRequest :: IsBonded { state_root_hash , era_id , protocol_version , public_key : validator , responder , } , QueueKind :: Regular , ) . await . or_else ( | error | { // Promote this error to a non-error case. // It's not an error that we can't find the era that was requested. if error . is_era_validators_missing ( ) { Ok ( false ) } else { Err ( error ) } } ) , } , } }
Checks whether the given validator is bonded in the given era.
Checks whether the given validator is bonded in the given era .
self
validator
PublicKey
era_id
EraId
latest_state_root_hash
Option<Digest>
protocol_version
ProtocolVersion
self
validator
PublicKey
era_id
EraId
latest_state_root_hash
Option<Digest>
protocol_version
ProtocolVersion