1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-keygen synced 2026-06-17 03:50:03 +02:00

key_search: refactor key_search_n() and key_search_nt() to proper names.

This commit is contained in:
Henrik Hautakoski 2020-01-10 10:56:32 +01:00
parent a4dec2e39b
commit 6dcc897fcf
5 changed files with 11 additions and 11 deletions

View file

@ -39,7 +39,7 @@ if (USE_THREADS)
if (Threads_FOUND)
# Add preprocessor flag
add_definitions( "-DHAVE_THREADS=1" )
set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/key_search_nt.cpp)
set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/key_search_mt.cpp)
endif (Threads_FOUND)
endif (USE_THREADS)

View file

@ -5,7 +5,7 @@
#include "key_search_helpers.h"
#include "key_search.h"
void key_search_n(const strlist_t& word_list, size_t n) {
void key_search(const strlist_t& word_list, size_t n) {
size_t count = 0;
struct ec_keypair pair;

View file

@ -27,10 +27,10 @@
#include "string.h"
#include "ec.h"
void key_search_n(const strlist_t& word_list, size_t n);
void key_search(const strlist_t& word_list, size_t n);
#ifdef HAVE_THREADS
void key_search_nt(const strlist_t& word_list, size_t n, size_t n_threads = 0);
void key_search_mt(const strlist_t& word_list, size_t n, size_t n_threads = 0);
#endif /* HAVE_THREADS */
#endif /* KEY_SEARCH_H */

View file

@ -15,7 +15,7 @@ unsigned int g_count;
std::mutex g_count_mtx;
// Thread process.
static void thr_proc(const strlist_t& word_list) {
static void _mt_search(const strlist_t& word_list) {
struct ec_keypair pair;
@ -43,14 +43,14 @@ static void thr_proc(const strlist_t& word_list) {
}
}
void key_search_nt(const strlist_t& word_list, size_t n, size_t n_threads) {
void key_search_mt(const strlist_t& word_list, size_t n, size_t n_threads) {
std::vector<std::thread> t;
// Not enough threads passed in by caller.
if (n_threads < 2) {
// Just use linear function.
key_search_n(word_list, n);
key_search(word_list, n);
return;
}
@ -62,11 +62,11 @@ void key_search_nt(const strlist_t& word_list, size_t n, size_t n_threads) {
// Launch them.
for(int i = 0; i < t.size(); i++) {
t[i] = std::thread(thr_proc, word_list);
t[i] = std::thread(_mt_search, word_list);
}
// Use main thread for 1 search
thr_proc(word_list);
_mt_search(word_list);
// Wait for all threads to compelete.
for(int i = 0; i < t.size(); i++) {

View file

@ -43,12 +43,12 @@
} \
}
#define n_thread_outp << ", Using: " << n_threads << " threads"
#define call_search key_search_nt(words, n, n_threads)
#define call_search key_search_mt(words, n, n_threads)
#else
#define n_thread_decl
#define n_thread_argv
#define n_thread_outp
#define call_search key_search_n(words, n)
#define call_search key_search(words, n)
#endif /* HAVE_THREADS */
void cmd_search(int argc, char **argv) {