2016-04-06 06:53:37 +00:00
|
|
|
//
|
|
|
|
// Created by mwo on 6/11/15.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "CmdLineOptions.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace xmreg
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Take the acc and *avv[] from the main() and check and parse
|
|
|
|
* all the options given
|
|
|
|
*/
|
|
|
|
CmdLineOptions::CmdLineOptions(int acc, const char *avv[]) {
|
|
|
|
|
|
|
|
positional_options_description p;
|
|
|
|
|
|
|
|
p.add("txhash", -1);
|
|
|
|
|
|
|
|
options_description desc(
|
2017-05-18 00:59:26 +00:00
|
|
|
"xmrblocks, Onion Monero Blockchain Explorer");
|
2016-04-06 06:53:37 +00:00
|
|
|
|
|
|
|
desc.add_options()
|
|
|
|
("help,h", value<bool>()->default_value(false)->implicit_value(true),
|
|
|
|
"produce help message")
|
2016-09-06 11:19:10 +00:00
|
|
|
("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
|
|
|
|
"use testnet blockchain")
|
2016-11-24 01:59:58 +00:00
|
|
|
("enable-pusher", value<bool>()->default_value(false)->implicit_value(true),
|
2017-05-18 00:59:26 +00:00
|
|
|
"enable signed transaction pusher")
|
2017-04-28 05:45:30 +00:00
|
|
|
("enable-mixin-details", value<bool>()->default_value(false)->implicit_value(true),
|
|
|
|
"enable mixin details for key images, e.g., timescale, mixin of mixins, in tx context")
|
2017-02-28 07:10:50 +00:00
|
|
|
("enable-key-image-checker", value<bool>()->default_value(false)->implicit_value(true),
|
|
|
|
"enable key images file checker")
|
|
|
|
("enable-output-key-checker", value<bool>()->default_value(false)->implicit_value(true),
|
|
|
|
"enable outputs key file checker")
|
2017-04-28 05:45:30 +00:00
|
|
|
("enable-json-api", value<bool>()->default_value(true),
|
|
|
|
"enable JSON REST api")
|
|
|
|
("enable-tx-cache", value<bool>()->default_value(false)->implicit_value(true),
|
2017-05-18 00:59:26 +00:00
|
|
|
"enable caching of transaction details")
|
2017-04-28 05:45:30 +00:00
|
|
|
("show-cache-times", value<bool>()->default_value(false)->implicit_value(true),
|
|
|
|
"show times of getting data from cache vs no cache")
|
|
|
|
("enable-block-cache", value<bool>()->default_value(false)->implicit_value(true),
|
|
|
|
"enable caching of block details")
|
2017-02-28 07:10:50 +00:00
|
|
|
("enable-autorefresh-option", value<bool>()->default_value(false)->implicit_value(true),
|
|
|
|
"enable users to have the index page on autorefresh")
|
2017-05-17 05:30:36 +00:00
|
|
|
("enable-emission-monitor", value<bool>()->default_value(false)->implicit_value(true),
|
|
|
|
"enable Monero total emission monitoring thread")
|
2016-04-13 08:46:08 +00:00
|
|
|
("port,p", value<string>()->default_value("8081"),
|
2017-05-18 00:59:26 +00:00
|
|
|
"default explorer port")
|
2017-04-28 05:45:30 +00:00
|
|
|
("testnet-url", value<string>()->default_value(""),
|
2017-05-18 00:59:26 +00:00
|
|
|
"you can specify testnet url, if you run it on mainnet. link will show on front page to testnet explorer")
|
2017-04-28 05:45:30 +00:00
|
|
|
("mainnet-url", value<string>()->default_value(""),
|
2017-05-18 00:59:26 +00:00
|
|
|
"you can specify mainnet url, if you run it on testnet. link will show on front page to mainnet explorer")
|
2017-03-03 22:25:24 +00:00
|
|
|
("no-blocks-on-index", value<string>()->default_value("10"),
|
|
|
|
"number of last blocks to be shown on index page")
|
2017-05-28 01:13:45 +00:00
|
|
|
("mempool-info-timeout", value<string>()->default_value("5000"),
|
2017-05-28 01:10:42 +00:00
|
|
|
"maximum time, in milliseconds, to wait for mempool data for the front page")
|
2017-06-05 05:27:11 +00:00
|
|
|
("mempool-refresh-time", value<string>()->default_value("15"),
|
2017-06-02 04:32:25 +00:00
|
|
|
"time, in seconds, for each refresh of mempool state")
|
2016-04-06 06:53:37 +00:00
|
|
|
("bc-path,b", value<string>(),
|
2017-05-18 00:59:26 +00:00
|
|
|
"path to lmdb folder of the blockchain, e.g., ~/.bitmonero/lmdb")
|
2016-12-19 01:47:19 +00:00
|
|
|
("ssl-crt-file", value<string>(),
|
2017-05-18 00:59:26 +00:00
|
|
|
"path to crt file for ssl (https) functionality")
|
2016-12-19 01:47:19 +00:00
|
|
|
("ssl-key-file", value<string>(),
|
2017-05-18 00:59:26 +00:00
|
|
|
"path to key file for ssl (https) functionality")
|
2016-04-13 08:46:08 +00:00
|
|
|
("deamon-url,d", value<string>()->default_value("http:://127.0.0.1:18081"),
|
2017-05-18 00:59:26 +00:00
|
|
|
"Monero deamon url");
|
2016-04-06 06:53:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
store(command_line_parser(acc, avv)
|
|
|
|
.options(desc)
|
|
|
|
.positional(p)
|
|
|
|
.run(), vm);
|
|
|
|
|
|
|
|
notify(vm);
|
|
|
|
|
|
|
|
if (vm.count("help"))
|
|
|
|
{
|
|
|
|
if (vm["help"].as<bool>())
|
|
|
|
cout << desc << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the value of the argument passed to the program
|
|
|
|
* in wrapped around boost::optional
|
|
|
|
*/
|
|
|
|
template<typename T>
|
|
|
|
boost::optional<T>
|
|
|
|
CmdLineOptions::get_option(const string & opt_name) const
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!vm.count(opt_name))
|
|
|
|
{
|
|
|
|
return boost::none;
|
|
|
|
}
|
|
|
|
|
|
|
|
return vm[opt_name].as<T>();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// explicit instantiations of get_option template function
|
|
|
|
template boost::optional<string>
|
|
|
|
CmdLineOptions::get_option<string>(const string & opt_name) const;
|
|
|
|
|
|
|
|
template boost::optional<bool>
|
|
|
|
CmdLineOptions::get_option<bool>(const string & opt_name) const;
|
|
|
|
|
|
|
|
template boost::optional<size_t>
|
|
|
|
CmdLineOptions::get_option<size_t>(const string & opt_name) const;
|
|
|
|
|
|
|
|
}
|