External generator
Good afternoon. Is it possible to make it possible to use an external generator for address mode and rnd160? The built-in generator does not know how to filter data and iterates over all characters in a row. Or modify the built-in generator to add filtering functionality.
#include <gmp.h>
#include
std::atomic
bool has_three_in_a_row(const std::string &s) { std::regex e("(.)\1{2,}"); return std::regex_search(s, e); }
void worker(mpz_t start, mpz_t end) { mpz_t i; mpz_init(i); mpz_set(i, start); while (mpz_cmp(i, end) <= 0) { char *hex_number_c_str = mpz_get_str(NULL, 16, i); std::string hex_number(hex_number_c_str); std::transform(hex_number.begin(), hex_number.end(), hex_number.begin(), ::toupper); free(hex_number_c_str); std::map<char, int> char_count; bool over_three = false; for (char c : hex_number) { char_count[c]++; if (char_count[c] > 3) { over_three = true; break; } } if (!over_three && !has_three_in_a_row(hex_number)) {
file_mutex.lock();
file << hex_number << "\n";
file_mutex.unlock();
}
mpz_add_ui(i, i, 1);
}
counter--;
mpz_clear(i);
}
int main() { mpz_t start, end; mpz_init_set_str(start, "20FFFFFFFFFFFFFFF", 16); mpz_init_set_str(end, "3FF00000000000000", 16);
file.open("out.txt");
unsigned int num_threads = std::thread::hardware_concurrency();
counter = num_threads;
std::vector<std::thread> threads;
for (unsigned int i = 0; i < num_threads; i++) {
mpz_t thread_start, thread_end;
mpz_init(thread_start);
mpz_init(thread_end);
mpz_t range, temp;
mpz_init(range);
mpz_init(temp);
mpz_sub(range, end, start);
mpz_fdiv_q_ui(range, range, num_threads);
mpz_mul_ui(temp, range, i);
mpz_add(thread_start, start, temp);
if (i == num_threads - 1) {
mpz_set(thread_end, end);
} else {
mpz_add(temp, range, thread_start);
mpz_sub_ui(thread_end, temp, 1);
}
threads.push_back(std::thread(worker, thread_start, thread_end));
mpz_clears(thread_start, thread_end, range, temp, NULL);
}
while (counter > 0) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
for (std::thread &t : threads) {
t.join();
}
file.close();
mpz_clears(start, end, NULL);
return 0;
}