mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-07-03 11:53:41 +02:00
cli/src/main.cpp: move usage() function to the top.
This commit is contained in:
parent
73ccd4be02
commit
51883f42ca
1 changed files with 41 additions and 41 deletions
|
|
@ -44,47 +44,6 @@ bool option_l33t = false;
|
||||||
size_t option_num_threads = eoskeygen::KeySearch::max_threads();
|
size_t option_num_threads = eoskeygen::KeySearch::max_threads();
|
||||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||||
|
|
||||||
int cmd_search(const eoskeygen::strlist_t& words, const eoskeygen::Dictionary& dict, int count) {
|
|
||||||
|
|
||||||
eoskeygen::KeySearch ks;
|
|
||||||
eoskeygen::CliKeySearchResult rs(dict);
|
|
||||||
|
|
||||||
ks.setCallback(&rs);
|
|
||||||
|
|
||||||
for(auto it = words.begin(); it != words.end(); it++) {
|
|
||||||
size_t p = libeosio::is_base58(*it);
|
|
||||||
if (p != std::string::npos) {
|
|
||||||
std::cerr << "The word '"
|
|
||||||
<< *it << "' contains an invalid non-base58 character '"
|
|
||||||
<< (*it)[p] << "'" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (option_l33t) {
|
|
||||||
for(std::size_t i = 0; i < words.size(); i++) {
|
|
||||||
ks.addList(eoskeygen::l33twords(words[i]));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ks.addList(words);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
|
||||||
ks.setThreadCount(option_num_threads);
|
|
||||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
|
||||||
|
|
||||||
std::cout << "Searching for " << count
|
|
||||||
<< " keys containing: " << eoskeygen::strlist::join(ks.getList(), ",")
|
|
||||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
|
||||||
<< ", Using: " << option_num_threads << " threads"
|
|
||||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
ks.find(count);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void usage(const char *name) {
|
void usage(const char *name) {
|
||||||
|
|
||||||
std::cout << name
|
std::cout << name
|
||||||
|
|
@ -142,6 +101,47 @@ void usage(const char *name) {
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cmd_search(const eoskeygen::strlist_t& words, const eoskeygen::Dictionary& dict, int count) {
|
||||||
|
|
||||||
|
eoskeygen::KeySearch ks;
|
||||||
|
eoskeygen::CliKeySearchResult rs(dict);
|
||||||
|
|
||||||
|
ks.setCallback(&rs);
|
||||||
|
|
||||||
|
for(auto it = words.begin(); it != words.end(); it++) {
|
||||||
|
size_t p = libeosio::is_base58(*it);
|
||||||
|
if (p != std::string::npos) {
|
||||||
|
std::cerr << "The word '"
|
||||||
|
<< *it << "' contains an invalid non-base58 character '"
|
||||||
|
<< (*it)[p] << "'" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option_l33t) {
|
||||||
|
for(std::size_t i = 0; i < words.size(); i++) {
|
||||||
|
ks.addList(eoskeygen::l33twords(words[i]));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ks.addList(words);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||||
|
ks.setThreadCount(option_num_threads);
|
||||||
|
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||||
|
|
||||||
|
std::cout << "Searching for " << count
|
||||||
|
<< " keys containing: " << eoskeygen::strlist::join(ks.getList(), ",")
|
||||||
|
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||||
|
<< ", Using: " << option_num_threads << " threads"
|
||||||
|
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
ks.find(count);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void cmd_benchmark(size_t num_keys) {
|
void cmd_benchmark(size_t num_keys) {
|
||||||
|
|
||||||
struct eoskeygen::benchmark_result res;
|
struct eoskeygen::benchmark_result res;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue