From c2d78c692b82eb7fd301678428bc02a8e0b699a8 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 18 May 2017 08:59:26 +0800 Subject: [PATCH] boost path used instead of strings for paths --- main.cpp | 2 +- src/CmdLineOptions.cpp | 22 +++++++++++----------- src/CurrentBlockchainStatus.cpp | 20 +++++++++----------- src/CurrentBlockchainStatus.h | 6 ++++-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/main.cpp b/main.cpp index a809719..e216f7a 100644 --- a/main.cpp +++ b/main.cpp @@ -180,7 +180,7 @@ int main(int ac, const char* av[]) { // found in emission_amount.txt file. xmreg::CurrentBlockchainStatus::blockchain_path - = blockchain_path.string(); + = blockchain_path; xmreg::CurrentBlockchainStatus::testnet = testnet; xmreg::CurrentBlockchainStatus::deamon_url diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp index e93bdec..1ae6493 100644 --- a/src/CmdLineOptions.cpp +++ b/src/CmdLineOptions.cpp @@ -18,7 +18,7 @@ namespace xmreg p.add("txhash", -1); options_description desc( - "xmrblocks, start Onion Monero Blockchain Explorer"); + "xmrblocks, Onion Monero Blockchain Explorer"); desc.add_options() ("help,h", value()->default_value(false)->implicit_value(true), @@ -26,7 +26,7 @@ namespace xmreg ("testnet,t", value()->default_value(false)->implicit_value(true), "use testnet blockchain") ("enable-pusher", value()->default_value(false)->implicit_value(true), - "enable pushing signed tx") + "enable signed transaction pusher") ("enable-mixin-details", value()->default_value(false)->implicit_value(true), "enable mixin details for key images, e.g., timescale, mixin of mixins, in tx context") ("enable-key-image-checker", value()->default_value(false)->implicit_value(true), @@ -34,11 +34,11 @@ namespace xmreg ("enable-output-key-checker", value()->default_value(false)->implicit_value(true), "enable outputs key file checker") ("enable-mempool-cache", value()->default_value(true), - "enable caching txs in the mempool") + "enable caching of transactions from the mempool") ("enable-json-api", value()->default_value(true), "enable JSON REST api") ("enable-tx-cache", value()->default_value(false)->implicit_value(true), - "enable caching of tx details") + "enable caching of transaction details") ("show-cache-times", value()->default_value(false)->implicit_value(true), "show times of getting data from cache vs no cache") ("enable-block-cache", value()->default_value(false)->implicit_value(true), @@ -48,21 +48,21 @@ namespace xmreg ("enable-emission-monitor", value()->default_value(false)->implicit_value(true), "enable Monero total emission monitoring thread") ("port,p", value()->default_value("8081"), - "default port") + "default explorer port") ("testnet-url", value()->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()->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()->default_value("10"), "number of last blocks to be shown on index page") ("bc-path,b", value(), - "path to lmdb blockchain") + "path to lmdb folder of the blockchain, e.g., ~/.bitmonero/lmdb") ("ssl-crt-file", value(), - "A path to crt file for ssl (https) functionality") + "path to crt file for ssl (https) functionality") ("ssl-key-file", value(), - "A path to key file for ssl (https) functionality") + "path to key file for ssl (https) functionality") ("deamon-url,d", value()->default_value("http:://127.0.0.1:18081"), - "monero address string"); + "Monero deamon url"); store(command_line_parser(acc, avv) diff --git a/src/CurrentBlockchainStatus.cpp b/src/CurrentBlockchainStatus.cpp index 2327e8e..90af54c 100644 --- a/src/CurrentBlockchainStatus.cpp +++ b/src/CurrentBlockchainStatus.cpp @@ -21,7 +21,7 @@ CurrentBlockchainStatus::init_monero_blockchain() mcore = unique_ptr(new xmreg::MicroCore{}); // initialize the core using the blockchain path - if (!mcore->init(blockchain_path)) + if (!mcore->init(blockchain_path.string())) { cerr << "Error accessing blockchain." << endl; return false; @@ -40,7 +40,7 @@ CurrentBlockchainStatus::start_monitor_blockchain_thread() { 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)) { @@ -148,7 +148,7 @@ bool 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); @@ -169,7 +169,7 @@ CurrentBlockchainStatus::save_current_emission_amount() bool 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); @@ -222,12 +222,10 @@ CurrentBlockchainStatus::load_current_emission_amount() } -string +bf::path CurrentBlockchainStatus::get_output_file_path() { - string emmision_saved_file = blockchain_path + output_file; - - return emmision_saved_file; + return blockchain_path / output_file; } @@ -243,13 +241,13 @@ CurrentBlockchainStatus::is_thread_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}; -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"}; uint64_t CurrentBlockchainStatus::blockchain_chunk_size {10000}; diff --git a/src/CurrentBlockchainStatus.h b/src/CurrentBlockchainStatus.h index 57e2010..5c8fa3a 100644 --- a/src/CurrentBlockchainStatus.h +++ b/src/CurrentBlockchainStatus.h @@ -20,6 +20,8 @@ namespace xmreg using namespace std; +namespace bf = boost::filesystem; + struct CurrentBlockchainStatus { @@ -43,7 +45,7 @@ struct CurrentBlockchainStatus } }; - static string blockchain_path; + static bf::path blockchain_path; static bool testnet; @@ -84,7 +86,7 @@ struct CurrentBlockchainStatus static Emission get_emission(); - static string + static bf::path get_output_file_path(); static bool