Print version on monero-lws-daemon startup (#213)

This commit is contained in:
Lee *!* Clagett
2025-12-02 20:27:58 -05:00
committed by Lee *!* Clagett
parent 24bdbb43d4
commit 506c3a871d

View File

@@ -44,6 +44,7 @@
#include "cryptonote_config.h" // monero/src/ #include "cryptonote_config.h" // monero/src/
#include "db/storage.h" #include "db/storage.h"
#include "error.h" #include "error.h"
#include "lws_version.h"
#include "options.h" #include "options.h"
#include "rest_server.h" #include "rest_server.h"
#include "scanner.h" #include "scanner.h"
@@ -84,6 +85,7 @@ namespace
const command_line::arg_descriptor<bool> auto_accept_creation; const command_line::arg_descriptor<bool> auto_accept_creation;
const command_line::arg_descriptor<bool> untrusted_daemon; const command_line::arg_descriptor<bool> untrusted_daemon;
const command_line::arg_descriptor<bool> regtest; const command_line::arg_descriptor<bool> regtest;
const command_line::arg_descriptor<bool> version;
static std::string get_default_zmq() static std::string get_default_zmq()
{ {
@@ -132,6 +134,7 @@ namespace
, auto_accept_creation{"auto-accept-creation", "New account creation requests are automatically accepted", false} , auto_accept_creation{"auto-accept-creation", "New account creation requests are automatically accepted", false}
, untrusted_daemon{"untrusted-daemon", "Perform (expensive) chain-verification and PoW checks", false} , untrusted_daemon{"untrusted-daemon", "Perform (expensive) chain-verification and PoW checks", false}
, regtest{"regtest", "Run in a regression testing mode", false} , regtest{"regtest", "Run in a regression testing mode", false}
, version{"version", "Display version and quit", false}
{} {}
void prepare(boost::program_options::options_description& description) const void prepare(boost::program_options::options_description& description) const
@@ -168,6 +171,7 @@ namespace
command_line::add_arg(description, auto_accept_creation); command_line::add_arg(description, auto_accept_creation);
command_line::add_arg(description, untrusted_daemon); command_line::add_arg(description, untrusted_daemon);
command_line::add_arg(description, regtest); command_line::add_arg(description, regtest);
command_line::add_arg(description, version);
} }
}; };
@@ -191,11 +195,17 @@ namespace
bool regtest; bool regtest;
}; };
void print_version(std::ostream& out)
{
std::cout << lws::version::name << " version " << lws::version::id << " commit " << lws::version::commit << std::endl;;
}
void print_help(std::ostream& out) void print_help(std::ostream& out)
{ {
boost::program_options::options_description description{"Options"}; boost::program_options::options_description description{"Options"};
options{}.prepare(description); options{}.prepare(description);
print_version(out);
out << "Usage: [options]" << std::endl; out << "Usage: [options]" << std::endl;
out << description; out << description;
} }
@@ -234,6 +244,12 @@ namespace
return boost::none; return boost::none;
} }
if (command_line::get_arg(args, opts.version))
{
print_version(std::cout);
return boost::none;
}
opts.set_network(args); // do this first, sets global variable :/ opts.set_network(args); // do this first, sets global variable :/
mlog_set_log_level(command_line::get_arg(args, opts.log_level)); mlog_set_log_level(command_line::get_arg(args, opts.log_level));
@@ -299,6 +315,8 @@ namespace
void run(program prog) void run(program prog)
{ {
MINFO(lws::version::name << " version " << lws::version::id << " commit " << lws::version::commit);
auto sub_address = prog.daemon_sub; auto sub_address = prog.daemon_sub;
boost::filesystem::create_directories(prog.db_path); boost::filesystem::create_directories(prog.db_path);