Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_block_overview(block_representation, coin_symbol='btc', txn_limit=None,
txn_offset=None, api_key=None):
"""
Takes a block_representation, coin_symbol and txn_limit and gets an overview
of that block, including up to X transaction ids.
Note that block_representation may be the block number or block hash
"""
assert is_valid_coin_symbol(coin_symbol)
assert is_valid_block_representation(
block_representation=block_representation,
coin_symbol=coin_symbol)
url = make_url(coin_symbol, **dict(blocks=block_representation))
params = {}
if api_key:
params['token'] = api_key
if txn_limit:
params['limit'] = txn_limit
if txn_offset:
params['txstart'] = txn_offset
r = requests.get(url, params=params, verify=True, timeout=TIMEOUT_IN_SECONDS)
response_dict = get_valid_json(r)
def get_blocks_overview(block_representation_list, coin_symbol='btc', txn_limit=None, api_key=None):
'''
Batch request version of get_blocks_overview
'''
for block_representation in block_representation_list:
assert is_valid_block_representation(
block_representation=block_representation,
coin_symbol=coin_symbol)
assert is_valid_coin_symbol(coin_symbol)
blocks = ';'.join([str(x) for x in block_representation_list])
url = make_url(coin_symbol, **dict(blocks=blocks))
logger.info(url)
params = {}
if api_key:
params['token'] = api_key
if txn_limit:
params['limit'] = txn_limit
r = requests.get(url, params=params, verify=True, timeout=TIMEOUT_IN_SECONDS)
def get_valid_metadata_identifier(coin_symbol, address, tx_hash, block_hash):
err_msg = 'Please supply only one of: address, tx_hash, or block_hash'
assert sum([1 for x in (address, tx_hash, block_hash) if x]) == 1, err_msg
if address:
assert is_valid_address_for_coinsymbol(
b58_address=address,
coin_symbol=coin_symbol), address
return dict(addrs=address)
elif tx_hash:
assert is_valid_hash(tx_hash), tx_hash
return dict(txs=tx_hash)
elif block_hash:
assert is_valid_block_representation(
block_representation=block_hash,
coin_symbol=coin_symbol)
return dict(blocks=block_hash)
else:
raise Exception('Logic Fail: This Should Not Be Possible')