Exemplo n.º 1
0
def _create_command(args):
    pool_config_file = get_pool_config_file(args)
    if pool_config_file is None:
        pool_config_file = 'pool_config.json'
    pool_user_config_file = get_pool_user_config_file(args)
    if pool_user_config_file is None:
        pool_user_config_file = 'pool_user_config.csv'

    pool_config_resolver = JsonFilePoolConfigurationResolver(pool_config_file)
    pool_user_config_resolver = CsvFilePoolUserConfigurationResolver(pool_user_config_file)
    pool_selector = PoolSelector(pool_config_resolver, pool_user_config_resolver)

    pool_selection_info = get_pool_selection_info(args)
    selected_pool_config = pool_selector.select_pool(pool_selection_info)
    if selected_pool_config is None:
        raise LookupError('No pool configuration in "' + pool_config_file + '" found')
    pool_config, pool_user_config = selected_pool_config
    pool_connection_info = resolve_connection_info(
        pool_config,
        pool_selection_info.currency_name_or_symbol,
        pool_selection_info.hash_algorithm,
        pool_selection_info.difficulty)
    if pool_connection_info is None:
        raise LookupError('No pool configuration in "' + pool_config_file + '" found')

    cmd_file_name = get_executive_file(args)
    if cmd_file_name is None:
        cmd_file_name = './cpuminer-multi/cpuminer'

    args = get_cpuminer_multi_args(args) + get_pool_args(pool_connection_info, pool_user_config)
    return Command(cmd_file_name, args)
    def test_no_pool_config_and_no_pool_user_config(self):
        pool_config_resolver = BufferPoolConfigurationResolver([])
        pool_user_config_resolver = BufferPoolUserConfigurationResolver([])
        pool_selector = PoolSelector(pool_config_resolver,
                                     pool_user_config_resolver)

        pool_selection_info = PoolSelectionInfo('pool1', 'currency1', 'algo1')

        configs = pool_selector.select_pool(pool_selection_info)

        self.assertIsNone(configs)
    def test_matches_pool_config_and_matches_pool_user_config(self):
        pool_config_resolver = BufferPoolConfigurationResolver(
            [PoolConfiguration('pool1', [])])
        pool_user_config_resolver = BufferPoolUserConfigurationResolver(
            [PoolUserConfiguration('pool1', 'user1', 'pass1')])
        pool_selector = PoolSelector(pool_config_resolver,
                                     pool_user_config_resolver)

        pool_selection_info = PoolSelectionInfo('pool1', 'currency1', 'algo1')

        configs = pool_selector.select_pool(pool_selection_info)

        self.assertIsNotNone(configs)

        pool_config, pool_user_config = configs

        self.assertEqual('pool1', pool_config.pool_name)
        self.assertEqual('pool1', pool_user_config.pool_name)