pub fn create_data_provider(
    data_provider_config: &DataProviderConfig,
    optional_nns_public_key: Option<ThresholdSigPublicKey>,
) -> Arc<dyn RegistryDataProvider> {
    let nns_data_provider = |urls: Vec<Url>| -> Arc<dyn RegistryDataProvider> {
        let registry_canister = RegistryCanister::new(urls);
        match optional_nns_public_key {
            Some(nns_pk) => Arc::new(CertifiedNnsDataProvider::new(registry_canister, nns_pk)),
            None => Arc::new(NnsDataProvider::new(registry_canister)),
        }
    };

    match data_provider_config {
        DataProviderConfig::RegistryCanisterUrl(url) => nns_data_provider(url.clone()),
        DataProviderConfig::ProtobufFile(path) => {
            Arc::new(ProtoRegistryDataProvider::load_from_file(path))
        }
        DataProviderConfig::Bootstrap {
            initial_registry_file,
            registry_canister_url,
        } => {
            let dp = BootstrapRegistryDataProvider::new(
                Arc::new(ProtoRegistryDataProvider::load_from_file(
                    initial_registry_file,
                )),
                nns_data_provider(registry_canister_url.clone()),
            );
            Arc::new(dp)
        }
        DataProviderConfig::LocalStore(path) => Arc::new(LocalStoreImpl::new(path)),
    }
}
/// Instantiate a data provider from a `DataProviderConfig`. In case of
/// `DataProviderConfig::Bootstrap` and
/// `DataProviderConfig::RegistryCanisterUrl`, a corresponding
/// `ThresholdSigPublicKey` can be provided to verify certified updates provided
/// by the registry canister.
Instantiate a data provider from a `DataProviderConfig`.
Instantiate a data provider from a ` DataProviderConfig ` .
pub fn create_data_provider(
    data_provider_config: &DataProviderConfig,
    optional_nns_public_key: Option<ThresholdSigPublicKey>,
) -> Arc<dyn RegistryDataProvider> {
    let nns_data_provider = |urls: Vec<Url>| -> Arc<dyn RegistryDataProvider> {
        let registry_canister = RegistryCanister::new(urls);
        match optional_nns_public_key {
            Some(nns_pk) => Arc::new(CertifiedNnsDataProvider::new(registry_canister, nns_pk)),
            None => Arc::new(NnsDataProvider::new(registry_canister)),
        }
    };
    match data_provider_config {
        DataProviderConfig::RegistryCanisterUrl(url) => nns_data_provider(url.clone()),
        DataProviderConfig::ProtobufFile(path) => {
            Arc::new(ProtoRegistryDataProvider::load_from_file(path))
        }
        DataProviderConfig::Bootstrap {
            initial_registry_file,
            registry_canister_url,
        } => {
            let dp = BootstrapRegistryDataProvider::new(
                Arc::new(ProtoRegistryDataProvider::load_from_file(
                    initial_registry_file,
                )),
                nns_data_provider(registry_canister_url.clone()),
            );
            Arc::new(dp)
        }
        DataProviderConfig::LocalStore(path) => Arc::new(LocalStoreImpl::new(path)),
    }
}
pub fn create_data_provider ( data_provider_config : & DataProviderConfig , optional_nns_public_key : Option < ThresholdSigPublicKey > , ) -> Arc < dyn RegistryDataProvider > { let nns_data_provider = | urls : Vec < Url > | -> Arc < dyn RegistryDataProvider > { let registry_canister = RegistryCanister :: new ( urls ) ; match optional_nns_public_key { Some ( nns_pk ) => Arc :: new ( CertifiedNnsDataProvider :: new ( registry_canister , nns_pk ) ) , None => Arc :: new ( NnsDataProvider :: new ( registry_canister ) ) , } } ; match data_provider_config { DataProviderConfig :: RegistryCanisterUrl ( url ) => nns_data_provider ( url . clone ( ) ) , DataProviderConfig :: ProtobufFile ( path ) => { Arc :: new ( ProtoRegistryDataProvider :: load_from_file ( path ) ) } DataProviderConfig :: Bootstrap { initial_registry_file , registry_canister_url , } => { let dp = BootstrapRegistryDataProvider :: new ( Arc :: new ( ProtoRegistryDataProvider :: load_from_file ( initial_registry_file , ) ) , nns_data_provider ( registry_canister_url . clone ( ) ) , ) ; Arc :: new ( dp ) } DataProviderConfig :: LocalStore ( path ) => Arc :: new ( LocalStoreImpl :: new ( path ) ) , } }
Instantiate a data provider from a `DataProviderConfig`.
Instantiate a data provider from a ` DataProviderConfig ` .
data_provider_config
&DataProviderConfig
optional_nns_public_key
Option<ThresholdSigPublicKey>
data_provider_config
&DataProviderConfig
optional_nns_public_key
Option<ThresholdSigPublicKey>