Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic gulps #5

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,3 @@ add_subdirectory(db_drivers)
add_subdirectory(easylogging++)
# fmt is shipped as subtree
add_subdirectory(fmt)
# activate extended color output for fmt
add_definitions(-DFMT_EXTENDED_COLORS)
27 changes: 21 additions & 6 deletions src/address_validator/address_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#define GULPS_CAT_MAJOR "addr_val"
#include "common/gulps.hpp"

#include "address_validator/address_validator.h"
#include "string_tools.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
Expand Down Expand Up @@ -98,19 +101,19 @@ bool address_validator::evaluate_address_attributes(const std::string &net_type,
bool valid = false;
if(net_type == "mainnet")
{
valid = get_account_address_from_str<MAINNET>(attr.info, addr_str, true);
valid = get_account_address_from_str<MAINNET>(attr.info, addr_str);
attr.network = valid ? "mainnet" : "";
attr.nettype = MAINNET;
}
else if(net_type == "testnet")
{
valid = get_account_address_from_str<TESTNET>(attr.info, addr_str, true);
valid = get_account_address_from_str<TESTNET>(attr.info, addr_str);
attr.network = valid ? "testnet" : "";
attr.nettype = TESTNET;
}
else if(net_type == "stagenet")
{
valid = get_account_address_from_str<STAGENET>(attr.info, addr_str, true);
valid = get_account_address_from_str<STAGENET>(attr.info, addr_str);
attr.network = valid ? "stagenet" : "";
attr.nettype = STAGENET;
}
Expand All @@ -125,7 +128,11 @@ void address_validator::init_options(
{
namespace po = boost::program_options;

desc.add_options()("network,n", po::value<std::string>(&m_network)->default_value("auto"), "network type (auto, mainnet, testnet, stagenet)")("filename,f", po::value<std::string>(&m_filename), "json file name, if not set result is printed to terminal")("human", po::value<bool>(&m_human)->zero_tokens()->default_value(false)->default_value(false), "human readable output")("address", po::value<std::vector<std::string>>(&m_address_strs), "ryo-currency address");
desc.add_options()
("network,n", po::value<std::string>(&m_network)->default_value("auto"), "network type (auto, mainnet, testnet, stagenet)")
("filename,f", po::value<std::string>(&m_filename), "json file name, if not set result is printed to terminal")
("human", po::value<bool>(&m_human)->zero_tokens()->default_value(false)->default_value(false), "human readable output")
("address", po::value<std::vector<std::string>>(&m_address_strs), "ryo-currency address");

pos_option.add("address", -1);
}
Expand All @@ -134,14 +141,14 @@ bool address_validator::validate_options()
{
if(m_address_strs.empty())
{
MERROR("No address given.");
GULPS_ERROR("No address given.");
return 1;
}

std::vector<std::string> networks = {"auto", "mainnet", "testnet", "stagenet"};
if(std::find(networks.begin(), networks.end(), m_network) == networks.end())
{
MERROR("Invalid/Unknown network type " << m_network);
GULPS_ERROR("Invalid/Unknown network type {}.", m_network);
return 2;
}
return 0;
Expand Down Expand Up @@ -192,10 +199,18 @@ int main(int argc, char *argv[])
po::options_description desc("Validate RYO/SUMOKOIN addresses and show properties\n\n"
"ryo-address-validator [OPTIONS] WALLET_ADDRESS [WALLET_ADDRESS...]\n\n"
"OPTIONS");

po::positional_options_description pos_option;

desc.add_options()("help,h", "print help message and exit");

gulps::inst().set_thread_tag("MAIN");

// We won't replace the custom output writer here, so just direct **our** errors to console
std::unique_ptr<gulps::gulps_output> out(new gulps::gulps_print_output(true, fmt::color::white));
out->add_filter([](const gulps::message& msg) -> bool { return msg.cat_major == GULPS_CAT_MAJOR && msg.lvl == gulps::LEVEL_ERROR; });
gulps::inst().add_output(std::move(out));

using namespace cryptonote;

address_validator validator{};
Expand Down
9 changes: 8 additions & 1 deletion src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ set(common_sources
password.cpp
perf_timer.cpp
threadpool.cpp
updates.cpp)
updates.cpp
string.cpp)

if (STACK_TRACE)
list(APPEND common_sources stack_trace.cpp)
Expand All @@ -63,6 +64,8 @@ endif()
set(common_headers)

set(common_private_headers
gulps.hpp
string.hpp
apply_permutation.h
base58.h
boost_serialization_helper.h
Expand Down Expand Up @@ -104,9 +107,13 @@ target_link_libraries(common
${Boost_THREAD_LIBRARY}
${Boost_REGEX_LIBRARY}
${Boost_CHRONO_LIBRARY}
fmt::fmt-header-only
PRIVATE
${OPENSSL_LIBRARIES}
${EXTRA_LIBRARIES})

# activate extended color output for fmt
target_compile_definitions(common PUBLIC -DFMT_EXTENDED_COLORS)

#monero_install_headers(common
# ${common_headers})
Loading