예제 #1
0
def coin_overview(request, coin_symbol):

    initial = {
        'coin_symbol': coin_symbol,
        'search_string': COIN_SYMBOL_MAPPINGS[coin_symbol]['example_address']
    }
    form = SearchForm(initial=initial)

    latest_bh = get_latest_block_height(coin_symbol=coin_symbol,
                                        api_key=BLOCKCYPHER_API_KEY)

    recent_blocks = get_blocks_overview(block_representation_list=list(
        reversed(range(latest_bh - 4, latest_bh + 1))),
                                        coin_symbol=coin_symbol,
                                        api_key=BLOCKCYPHER_API_KEY)

    recent_blocks = sorted(recent_blocks,
                           key=lambda k: k['height'],
                           reverse=True)
    fees = get_blockchain_fee_estimates(coin_symbol=coin_symbol,
                                        api_key=BLOCKCYPHER_API_KEY)

    fees['high_fee_per_kb__smalltx'] = fees['high_fee_per_kb'] / 4
    fees['medium_fee_per_kb__smalltx'] = fees['medium_fee_per_kb'] / 4
    fees['low_fee_per_kb__smalltx'] = fees['low_fee_per_kb'] / 4
    # import pprint; pprint.pprint(recent_blocks, width=1)

    recent_txs = get_broadcast_transactions(coin_symbol=coin_symbol,
                                            api_key=BLOCKCYPHER_API_KEY,
                                            limit=10)

    recent_txs_filtered = []
    tx_hashes_seen = set([])
    for recent_tx in recent_txs:
        if recent_tx['hash'] in tx_hashes_seen:
            continue
        else:
            tx_hashes_seen.add(recent_tx['hash'])
            recent_txs_filtered.append(recent_tx)

    # sort recent txs by order (they're not always returning in order)
    recent_txs_filtered = sorted(recent_txs_filtered,
                                 key=itemgetter('received'),
                                 reverse=True)

    fee_api_url = 'https://api.blockcypher.com/v1/%s/%s' % (
        COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_code'],
        COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_network'],
    )

    return {
        'coin_symbol': coin_symbol,
        'form': form,
        'recent_blocks': recent_blocks,
        'recent_txs': recent_txs_filtered,
        'fees': fees,
        'fee_api_url': fee_api_url,
        'BLOCKCYPHER_PUBLIC_KEY': BLOCKCYPHER_PUBLIC_KEY,
    }
예제 #2
0
def coin_overview(request, coin_symbol):

    initial = {
            'coin_symbol': coin_symbol,
            'search_string': COIN_SYMBOL_MAPPINGS[coin_symbol]['example_address']
            }
    form = SearchForm(initial=initial)

    latest_bh = get_latest_block_height(coin_symbol=coin_symbol, api_key=BLOCKCYPHER_API_KEY)

    recent_blocks = get_blocks_overview(
            block_representation_list=list(reversed(range(latest_bh-4, latest_bh+1))),
            coin_symbol=coin_symbol,
            api_key=BLOCKCYPHER_API_KEY)
    recent_blocks = sorted(recent_blocks, key=lambda k: k['height'], reverse=True)
    fees = get_blockchain_fee_estimates(coin_symbol=coin_symbol, api_key=BLOCKCYPHER_API_KEY)

    fees['high_fee_per_kb__smalltx'] = fees['high_fee_per_kb']/4
    fees['medium_fee_per_kb__smalltx'] = fees['medium_fee_per_kb']/4
    fees['low_fee_per_kb__smalltx'] = fees['low_fee_per_kb']/4
    # import pprint; pprint.pprint(recent_blocks, width=1)

    recent_txs = get_broadcast_transactions(coin_symbol=coin_symbol,
            api_key=BLOCKCYPHER_API_KEY,
            limit=10)

    recent_txs_filtered = []
    tx_hashes_seen = set([])
    for recent_tx in recent_txs:
        if recent_tx['hash'] in tx_hashes_seen:
            continue
        else:
            tx_hashes_seen.add(recent_tx['hash'])
            recent_txs_filtered.append(recent_tx)

    # sort recent txs by order (they're not always returning in order)
    recent_txs_filtered = sorted(recent_txs_filtered, key=itemgetter('received'), reverse=True)

    fee_api_url = 'https://api.blockcypher.com/v1/%s/%s' % (
            COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_code'],
            COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_network'],
            )

    return {
            'coin_symbol': coin_symbol,
            'form': form,
            'recent_blocks': recent_blocks,
            'recent_txs': recent_txs_filtered,
            'fees': fees,
            'fee_api_url': fee_api_url,
            'BLOCKCYPHER_PUBLIC_KEY': BLOCKCYPHER_PUBLIC_KEY,
            }
예제 #3
0
def coin_overview(request, coin_symbol):

    initial = {
        'coin_symbol': coin_symbol,
        'search_string': COIN_SYMBOL_MAPPINGS[coin_symbol]['example_address']
    }
    form = SearchForm(initial=initial)

    latest_bh = get_latest_block_height(coin_symbol=coin_symbol,
                                        api_key=BLOCKCYPHER_API_KEY)

    recent_blocks = get_blocks_overview(block_representation_list=list(
        reversed(range(latest_bh - 4, latest_bh + 1))),
                                        coin_symbol=coin_symbol,
                                        api_key=BLOCKCYPHER_API_KEY)
    recent_blocks = sorted(recent_blocks,
                           key=lambda k: k['height'],
                           reverse=True)
    #import pprint; pprint.pprint(recent_blocks, width=1)

    recent_txs = get_broadcast_transactions(coin_symbol=coin_symbol,
                                            api_key=BLOCKCYPHER_API_KEY,
                                            limit=10)

    recent_txs_filtered = []
    tx_hashes_seen = set([])
    for recent_tx in recent_txs:
        if recent_tx['hash'] in tx_hashes_seen:
            continue
        else:
            tx_hashes_seen.add(recent_tx['hash'])
            recent_txs_filtered.append(recent_tx)

    # sort recent txs by order (they're not always returning in order)
    recent_txs_filtered = sorted(recent_txs_filtered,
                                 key=itemgetter('received'),
                                 reverse=True)

    return {
        'coin_symbol': coin_symbol,
        'form': form,
        'recent_blocks': recent_blocks,
        'recent_txs': recent_txs_filtered,
        'BLOCKCYPHER_PUBLIC_KEY': BLOCKCYPHER_PUBLIC_KEY,
    }
예제 #4
0
파일: views.py 프로젝트: 5mil/explorer
def coin_overview(request, coin_symbol):

    initial = {
            'coin_symbol': coin_symbol,
            'search_string': COIN_SYMBOL_MAPPINGS[coin_symbol]['example_address']
            }
    form = SearchForm(initial=initial)

    latest_bh = get_latest_block_height(coin_symbol=coin_symbol, api_key=BLOCKCYPHER_API_KEY)

    recent_blocks = get_blocks_overview(
            block_representation_list=list(reversed(range(latest_bh-4, latest_bh+1))),
            coin_symbol=coin_symbol,
            api_key=BLOCKCYPHER_API_KEY)
    recent_blocks = sorted(recent_blocks, key=lambda k: k['height'], reverse=True)
    #import pprint; pprint.pprint(recent_blocks, width=1)

    recent_txs = get_broadcast_transactions(coin_symbol=coin_symbol,
            api_key=BLOCKCYPHER_API_KEY,
            limit=10)

    recent_txs_filtered = []
    tx_hashes_seen = set([])
    for recent_tx in recent_txs:
        if recent_tx['hash'] in tx_hashes_seen:
            continue
        else:
            tx_hashes_seen.add(recent_tx['hash'])
            recent_txs_filtered.append(recent_tx)

    # sort recent txs by order (they're not always returning in order)
    recent_txs_filtered = sorted(recent_txs_filtered, key=itemgetter('received'), reverse=True)

    return {
            'coin_symbol': coin_symbol,
            'form': form,
            'recent_blocks': recent_blocks,
            'recent_txs': recent_txs_filtered,
            'BLOCKCYPHER_PUBLIC_KEY': BLOCKCYPHER_PUBLIC_KEY,
            }