boost path used instead of strings for paths

This commit is contained in:
moneroexamples 2017-05-18 08:59:26 +08:00
parent 9c57d8b3a3
commit c2d78c692b
4 changed files with 25 additions and 25 deletions

View File

@ -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

View File

@ -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<bool>()->default_value(false)->implicit_value(true),
@ -26,7 +26,7 @@ namespace xmreg
("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
"use testnet blockchain")
("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 for key images, e.g., timescale, mixin of mixins, in tx context")
("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 outputs key file checker")
("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 REST api")
("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 times of getting data from cache vs no cache")
("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 Monero total emission monitoring thread")
("port,p", value<string>()->default_value("8081"),
"default port")
"default explorer port")
("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(""),
"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"),
"number of last blocks to be shown on index page")
("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>(),
"A path to crt file for ssl (https) functionality")
"path to crt file for ssl (https) functionality")
("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"),
"monero address string");
"Monero deamon url");
store(command_line_parser(acc, avv)

View File

@ -21,7 +21,7 @@ CurrentBlockchainStatus::init_monero_blockchain()
mcore = unique_ptr<xmreg::MicroCore>(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};

View File

@ -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