Skip to content

Commit

Permalink
Add code for provider_name again
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryp Toon committed Dec 24, 2024
1 parent b6110cf commit bb98235
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions bitcoinlib/services/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,19 @@ def __init__(self, network=DEFAULT_NETWORK, min_providers=1, max_providers=1, pr
raise ServiceError("Provider '%s' not found in provider definitions" % p)

self.providers = {}
for p in self.providers_defined:
if ((self.providers_defined[p]['network'] == network or self.providers_defined[p]['network'] == '') and \
(not providers or self.providers_defined[p]['provider'] in providers)
and (providers or self.providers_defined[p]['priority'])):
self.providers.update({p: self.providers_defined[p]})
exclude_providers_keys = {pi: self.providers[pi]['provider'] for pi in self.providers if self.providers[pi]['provider'] in exclude_providers}.keys()

if provider_name:
if provider_name not in self.providers_defined:
raise ServiceError("Provider with name '%s' not found in provider definitions" % provider_name)
if self.providers_defined[provider_name]['network'] != self.network:
raise ServiceError("Network from provider '%s' is different than Service network" % provider_name)
self.providers.update({provider_name: self.providers_defined[provider_name]})
else:
for p in self.providers_defined:
if (self.providers_defined[p]['network'] == network or self.providers_defined[p]['network'] == '') and \
(not providers or self.providers_defined[p]['provider'] in providers):
self.providers.update({p: self.providers_defined[p]})
exclude_providers_keys = {pi: self.providers[pi]['provider'] for
pi in self.providers if self.providers[pi]['provider'] in exclude_providers}.keys()
for provider_key in exclude_providers_keys:
del(self.providers[provider_key])

Expand Down

0 comments on commit bb98235

Please sign in to comment.