1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-keygen synced 2026-07-04 12:03:41 +02:00

key_search: make _thr_proc() a method to KeySearch class.

This commit is contained in:
Henrik Hautakoski 2020-02-17 14:39:09 +01:00
parent 34c24eb710
commit 01fc8911a3
2 changed files with 6 additions and 4 deletions

View file

@ -54,6 +54,8 @@ public :
protected : protected :
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
void _thr_proc();
void _search_mt(size_t n); void _search_mt(size_t n);
#endif /* HAVE_THREADS */ #endif /* HAVE_THREADS */

View file

@ -41,7 +41,7 @@ std::size_t 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) { void KeySearch::_thr_proc() {
struct ec_keypair pair; struct ec_keypair pair;
@ -49,7 +49,7 @@ static void _thr_proc(const strlist_t& word_list) {
struct key_result res; struct key_result res;
ec_generate_key(&pair); ec_generate_key(&pair);
if (key_contains_word(&pair, word_list, &res)) { if (key_contains_word(&pair, m_words, &res)) {
// Guard output with mutex, so we don't get // Guard output with mutex, so we don't get
// interrupted mid write and can write to g_count safely. // interrupted mid write and can write to g_count safely.
@ -86,11 +86,11 @@ void KeySearch::_search_mt(size_t n)
// Launch them. // Launch them.
for(std::size_t i = 0; i < t.size(); i++) { for(std::size_t i = 0; i < t.size(); i++) {
t[i] = std::thread(_thr_proc, m_words); t[i] = std::thread(&KeySearch::_thr_proc, this);
} }
// Use main thread for 1 search // Use main thread for 1 search
_thr_proc(m_words); _thr_proc();
// Wait for all threads to compelete. // Wait for all threads to compelete.
for(std::size_t i = 0; i < t.size(); i++) { for(std::size_t i = 0; i < t.size(); i++) {