mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-06-18 04:00:03 +02:00
Decouple key_search_result() and KeySearch class with an interface.
This commit is contained in:
parent
a417390bb7
commit
d9634f334b
8 changed files with 84 additions and 25 deletions
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
namespace eoskeygen {
|
||||
|
||||
class IKeySearchResult;
|
||||
|
||||
class KeySearch
|
||||
{
|
||||
public :
|
||||
|
|
@ -45,14 +47,14 @@ public :
|
|||
// Add a list of words to search for.
|
||||
void addList(const strlist_t& list);
|
||||
|
||||
void addDictionary(const Dictionary& dictionary);
|
||||
|
||||
// get the list of words to search for.
|
||||
const strlist_t& getList();
|
||||
|
||||
// Clears the search list.
|
||||
void clear();
|
||||
|
||||
void setCallback(IKeySearchResult* callback);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
// Set the number of threads to use while searching.
|
||||
void setThreadCount(size_t num);
|
||||
|
|
@ -79,13 +81,12 @@ protected :
|
|||
// List of words to search for.
|
||||
strlist_t m_words;
|
||||
|
||||
// Dictionary to use when we find a search result.
|
||||
Dictionary m_dict;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
// Number of threads to use.
|
||||
size_t m_threads;
|
||||
#endif /* HAVE_THREADS */
|
||||
|
||||
IKeySearchResult* m_callback;
|
||||
};
|
||||
|
||||
} // namespace eoskeygen
|
||||
|
|
|
|||
40
include/eoskeygen/key_search_result.h
Normal file
40
include/eoskeygen/key_search_result.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef EOSIOKEYGEN_KEY_SEARCH_RESULT_H
|
||||
#define EOSIOKEYGEN_KEY_SEARCH_RESULT_H
|
||||
|
||||
#include <eoskeygen/key_search.h>
|
||||
|
||||
namespace eoskeygen {
|
||||
|
||||
class IKeySearchResult
|
||||
{
|
||||
public :
|
||||
|
||||
virtual void onResult(const struct ec_keypair* key, const struct KeySearch::result& result) = 0;
|
||||
};
|
||||
|
||||
} // namespace eoskeygen
|
||||
|
||||
#endif /* EOSIOKEYGEN_KEY_SEARCH_RESULT_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue