mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-07-03 11:53:41 +02:00
key_search: refactor key_search_n() and key_search_nt() to proper names.
This commit is contained in:
parent
a4dec2e39b
commit
6dcc897fcf
5 changed files with 11 additions and 11 deletions
|
|
@ -39,7 +39,7 @@ if (USE_THREADS)
|
||||||
if (Threads_FOUND)
|
if (Threads_FOUND)
|
||||||
# Add preprocessor flag
|
# Add preprocessor flag
|
||||||
add_definitions( "-DHAVE_THREADS=1" )
|
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 (Threads_FOUND)
|
||||||
endif (USE_THREADS)
|
endif (USE_THREADS)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include "key_search_helpers.h"
|
#include "key_search_helpers.h"
|
||||||
#include "key_search.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;
|
size_t count = 0;
|
||||||
struct ec_keypair pair;
|
struct ec_keypair pair;
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "ec.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
|
#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 /* HAVE_THREADS */
|
||||||
|
|
||||||
#endif /* KEY_SEARCH_H */
|
#endif /* KEY_SEARCH_H */
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ unsigned int g_count;
|
||||||
std::mutex g_count_mtx;
|
std::mutex g_count_mtx;
|
||||||
|
|
||||||
// Thread process.
|
// Thread process.
|
||||||
static void thr_proc(const strlist_t& word_list) {
|
static void _mt_search(const strlist_t& word_list) {
|
||||||
|
|
||||||
struct ec_keypair pair;
|
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;
|
std::vector<std::thread> t;
|
||||||
|
|
||||||
// Not enough threads passed in by caller.
|
// Not enough threads passed in by caller.
|
||||||
if (n_threads < 2) {
|
if (n_threads < 2) {
|
||||||
// Just use linear function.
|
// Just use linear function.
|
||||||
key_search_n(word_list, n);
|
key_search(word_list, n);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,11 +62,11 @@ void key_search_nt(const strlist_t& word_list, size_t n, size_t n_threads) {
|
||||||
|
|
||||||
// Launch them.
|
// Launch them.
|
||||||
for(int i = 0; i < t.size(); i++) {
|
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
|
// Use main thread for 1 search
|
||||||
thr_proc(word_list);
|
_mt_search(word_list);
|
||||||
|
|
||||||
// Wait for all threads to compelete.
|
// Wait for all threads to compelete.
|
||||||
for(int i = 0; i < t.size(); i++) {
|
for(int i = 0; i < t.size(); i++) {
|
||||||
|
|
@ -43,12 +43,12 @@
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#define n_thread_outp << ", Using: " << n_threads << " threads"
|
#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
|
#else
|
||||||
#define n_thread_decl
|
#define n_thread_decl
|
||||||
#define n_thread_argv
|
#define n_thread_argv
|
||||||
#define n_thread_outp
|
#define n_thread_outp
|
||||||
#define call_search key_search_n(words, n)
|
#define call_search key_search(words, n)
|
||||||
#endif /* HAVE_THREADS */
|
#endif /* HAVE_THREADS */
|
||||||
|
|
||||||
void cmd_search(int argc, char **argv) {
|
void cmd_search(int argc, char **argv) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue