예제 #1
0
def _aggregate_miner_data(raw_data):
    data_by_miner = groupby(0, raw_data)

    for miner, miner_data in data_by_miner.items():
        _, block_hashes, gas_prices = map(set, zip(*miner_data))
        yield MinerData(
            miner,
            len(set(block_hashes)),
            min(gas_prices),
            percentile(gas_prices, percentile=15))
def _aggregate_miner_data(raw_data):
    data_by_miner = groupby(0, raw_data)

    for miner, miner_data in data_by_miner.items():
        _, block_hashes, gas_prices = map(set, zip(*miner_data))
        try:
            price_percentile = percentile(gas_prices, percentile=20)
        except InsufficientData:
            price_percentile = min(gas_prices)
        yield MinerData(miner, len(set(block_hashes)), min(gas_prices),
                        price_percentile)
예제 #3
0
def validate_abi(abi):
    """
    Helper function for validating an ABI
    """
    if not is_list_like(abi):
        raise ValueError("'abi' is not a list")

    if not all(is_dict(e) for e in abi):
        raise ValueError("'abi' is not a list of dictionaries")

    functions = filter_by_type('function', abi)
    selectors = groupby(compose(encode_hex, function_abi_to_4byte_selector),
                        functions)
    duplicates = valfilter(lambda funcs: len(funcs) > 1, selectors)
    if duplicates:
        raise ValueError('Abi contains functions with colliding selectors. '
                         'Functions {0}'.format(
                             _prepare_selector_collision_msg(duplicates)))