boost path used instead of strings for paths

master
moneroexamples 8 years ago
parent 9c57d8b3a3
commit c2d78c692b

@ -180,7 +180,7 @@ int main(int ac, const char* av[]) {
// found in emission_amount.txt file. // found in emission_amount.txt file.
xmreg::CurrentBlockchainStatus::blockchain_path xmreg::CurrentBlockchainStatus::blockchain_path
= blockchain_path.string(); = blockchain_path;
xmreg::CurrentBlockchainStatus::testnet xmreg::CurrentBlockchainStatus::testnet
= testnet; = testnet;
xmreg::CurrentBlockchainStatus::deamon_url xmreg::CurrentBlockchainStatus::deamon_url

@ -18,7 +18,7 @@ namespace xmreg
p.add("txhash", -1); p.add("txhash", -1);
options_description desc( options_description desc(
"xmrblocks, start Onion Monero Blockchain Explorer"); "xmrblocks, Onion Monero Blockchain Explorer");
desc.add_options() desc.add_options()
("help,h", value<bool>()->default_value(false)->implicit_value(true), ("help,h", value<bool>()->default_value(false)->implicit_value(true),
@ -26,7 +26,7 @@ namespace xmreg
("testnet,t", value<bool>()->default_value(false)->implicit_value(true), ("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
"use testnet blockchain") "use testnet blockchain")
("enable-pusher", value<bool>()->default_value(false)->implicit_value(true), ("enable-pusher", value<bool>()->default_value(false)->implicit_value(true),
"enable pushing signed tx") "enable signed transaction pusher")
("enable-mixin-details", value<bool>()->default_value(false)->implicit_value(true), ("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") "enable mixin details for key images, e.g., timescale, mixin of mixins, in tx context")
("enable-key-image-checker", value<bool>()->default_value(false)->implicit_value(true), ("enable-key-image-checker", value<bool>()->default_value(false)->implicit_value(true),
@ -34,11 +34,11 @@ namespace xmreg
("enable-output-key-checker", value<bool>()->default_value(false)->implicit_value(true), ("enable-output-key-checker", value<bool>()->default_value(false)->implicit_value(true),
"enable outputs key file checker") "enable outputs key file checker")
("enable-mempool-cache", value<bool>()->default_value(true), ("enable-mempool-cache", value<bool>()->default_value(true),
"enable caching txs in the mempool") "enable caching of transactions from the mempool")
("enable-json-api", value<bool>()->default_value(true), ("enable-json-api", value<bool>()->default_value(true),
"enable JSON REST api") "enable JSON REST api")
("enable-tx-cache", value<bool>()->default_value(false)->implicit_value(true), ("enable-tx-cache", value<bool>()->default_value(false)->implicit_value(true),
"enable caching of tx details") "enable caching of transaction details")
("show-cache-times", value<bool>()->default_value(false)->implicit_value(true), ("show-cache-times", value<bool>()->default_value(false)->implicit_value(true),
"show times of getting data from cache vs no cache") "show times of getting data from cache vs no cache")
("enable-block-cache", value<bool>()->default_value(false)->implicit_value(true), ("enable-block-cache", value<bool>()->default_value(false)->implicit_value(true),
@ -48,21 +48,21 @@ namespace xmreg
("enable-emission-monitor", value<bool>()->default_value(false)->implicit_value(true), ("enable-emission-monitor", value<bool>()->default_value(false)->implicit_value(true),
"enable Monero total emission monitoring thread") "enable Monero total emission monitoring thread")
("port,p", value<string>()->default_value("8081"), ("port,p", value<string>()->default_value("8081"),
"default port") "default explorer port")
("testnet-url", value<string>()->default_value(""), ("testnet-url", value<string>()->default_value(""),
"you can specifiy testnet url, if you run it on mainet. link will show on front page to testnet explorer") "you can specify testnet url, if you run it on mainnet. link will show on front page to testnet explorer")
("mainnet-url", value<string>()->default_value(""), ("mainnet-url", value<string>()->default_value(""),
"you can specifiy mainnet url, if you run it on testnet. link will show on front page to mainnet explorer") "you can specify mainnet url, if you run it on testnet. link will show on front page to mainnet explorer")
("no-blocks-on-index", value<string>()->default_value("10"), ("no-blocks-on-index", value<string>()->default_value("10"),
"number of last blocks to be shown on index page") "number of last blocks to be shown on index page")
("bc-path,b", value<string>(), ("bc-path,b", value<string>(),
"path to lmdb blockchain") "path to lmdb folder of the blockchain, e.g., ~/.bitmonero/lmdb")
("ssl-crt-file", value<string>(), ("ssl-crt-file", value<string>(),
"A path to crt file for ssl (https) functionality") "path to crt file for ssl (https) functionality")
("ssl-key-file", value<string>(), ("ssl-key-file", value<string>(),
"A path to key file for ssl (https) functionality") "path to key file for ssl (https) functionality")
("deamon-url,d", value<string>()->default_value("http:://127.0.0.1:18081"), ("deamon-url,d", value<string>()->default_value("http:://127.0.0.1:18081"),
"monero address string"); "Monero deamon url");
store(command_line_parser(acc, avv) store(command_line_parser(acc, avv)

@ -21,7 +21,7 @@ CurrentBlockchainStatus::init_monero_blockchain()
mcore = unique_ptr<xmreg::MicroCore>(new xmreg::MicroCore{}); mcore = unique_ptr<xmreg::MicroCore>(new xmreg::MicroCore{});
// initialize the core using the blockchain path // initialize the core using the blockchain path
if (!mcore->init(blockchain_path)) if (!mcore->init(blockchain_path.string()))
{ {
cerr << "Error accessing blockchain." << endl; cerr << "Error accessing blockchain." << endl;
return false; return false;
@ -40,7 +40,7 @@ CurrentBlockchainStatus::start_monitor_blockchain_thread()
{ {
total_emission_atomic = Emission {0, 0, 0}; total_emission_atomic = Emission {0, 0, 0};
string emmision_saved_file = get_output_file_path(); string emmision_saved_file = get_output_file_path().string();
if (boost::filesystem::exists(emmision_saved_file)) if (boost::filesystem::exists(emmision_saved_file))
{ {
@ -148,7 +148,7 @@ bool
CurrentBlockchainStatus::save_current_emission_amount() CurrentBlockchainStatus::save_current_emission_amount()
{ {
string emmision_saved_file = get_output_file_path(); string emmision_saved_file = get_output_file_path().string();
ofstream out(emmision_saved_file); ofstream out(emmision_saved_file);
@ -169,7 +169,7 @@ CurrentBlockchainStatus::save_current_emission_amount()
bool bool
CurrentBlockchainStatus::load_current_emission_amount() CurrentBlockchainStatus::load_current_emission_amount()
{ {
string emmision_saved_file = get_output_file_path(); string emmision_saved_file = get_output_file_path().string();
string last_saved_emmision = xmreg::read(emmision_saved_file); string last_saved_emmision = xmreg::read(emmision_saved_file);
@ -222,12 +222,10 @@ CurrentBlockchainStatus::load_current_emission_amount()
} }
string bf::path
CurrentBlockchainStatus::get_output_file_path() CurrentBlockchainStatus::get_output_file_path()
{ {
string emmision_saved_file = blockchain_path + output_file; return blockchain_path / output_file;
return emmision_saved_file;
} }
@ -243,11 +241,11 @@ CurrentBlockchainStatus::is_thread_running()
return is_running; return is_running;
} }
string CurrentBlockchainStatus::blockchain_path{"/home/mwo/.bitmonero/lmdb"}; bf::path CurrentBlockchainStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"};
bool CurrentBlockchainStatus::testnet {false}; bool CurrentBlockchainStatus::testnet {false};
string CurrentBlockchainStatus::output_file {"/emission_amount.txt"}; string CurrentBlockchainStatus::output_file {"emission_amount.txt"};
string CurrentBlockchainStatus::deamon_url {"http:://127.0.0.1:18081"}; string CurrentBlockchainStatus::deamon_url {"http:://127.0.0.1:18081"};

@ -20,6 +20,8 @@ namespace xmreg
using namespace std; using namespace std;
namespace bf = boost::filesystem;
struct CurrentBlockchainStatus struct CurrentBlockchainStatus
{ {
@ -43,7 +45,7 @@ struct CurrentBlockchainStatus
} }
}; };
static string blockchain_path; static bf::path blockchain_path;
static bool testnet; static bool testnet;
@ -84,7 +86,7 @@ struct CurrentBlockchainStatus
static Emission static Emission
get_emission(); get_emission();
static string static bf::path
get_output_file_path(); get_output_file_path();
static bool static bool

Loading…
Cancel
Save