Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions blockapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ def get_balance_from_random_api(symbol, address):
"""Get balance for currency from random API (APIs with API keys are not supported)."""
return _call_method_from_random_api(symbol, address, 'get_balance')


def get_shuffled_suitable_api_classes_for_coin(symbol, address):
api_classes = get_shuffled_api_classes_for_coin(symbol)
filtered_api_classes = filter_suitable_api_classes(api_classes, symbol,
address)
return filtered_api_classes


def _call_method_from_random_api(symbol, address, method):
filtered_api_classes = get_shuffled_suitable_api_classes_for_coin(symbol,
address)
Expand All @@ -73,8 +75,9 @@ def get_shuffled_api_classes_for_coin(symbol):


def get_api_classes_for_coin(symbol):

return [i for i in get_active_api_classes() if
i.symbol and i.symbol == symbol]
(i.symbol and i.symbol == symbol) or (symbol in i.supported_cryptos)]


def filter_suitable_api_classes(api_classes, symbol, address):
Expand All @@ -96,8 +99,10 @@ def get_random_api_class_for_coin(symbol, exclude=None):


def get_all_supported_coins():
return list(set(c.symbol for c in get_active_api_classes()
if c.symbol))
coins = set()
for c in get_active_api_classes():
coins |= c.supported_cryptos
return list(coins)


def get_active_api_classes():
Expand Down
1 change: 1 addition & 0 deletions blockapi/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def filter_unconfirmed_txs(txs):

class BlockchainAPI(Service, BlockchainInterface, ABC):
symbol = None
supported_cryptos = set()

def __init__(self, address, api_key=None):
Service.__init__(self, api_key)
Expand Down