diff --git a/main.cpp b/main.cpp index 79df005..5bd5386 100644 --- a/main.cpp +++ b/main.cpp @@ -51,6 +51,7 @@ main(int ac, const char* av[]) auto mainnet_url = opts.get_option("mainnet-url"); auto network_info_timeout_opt = opts.get_option("network-info-timeout"); auto mempool_info_timeout_opt = opts.get_option("mempool-info-timeout"); + auto mempool_refresh_time_opt = opts.get_option("mempool-refresh-time"); auto testnet_opt = opts.get_option("testnet"); auto enable_key_image_checker_opt = opts.get_option("enable-key-image-checker"); auto enable_output_key_checker_opt = opts.get_option("enable-output-key-checker"); @@ -157,6 +158,7 @@ main(int ac, const char* av[]) uint64_t network_info_timeout {1000}; uint64_t mempool_info_timeout {5000}; + try { network_info_timeout = boost::lexical_cast(*network_info_timeout_opt); @@ -168,9 +170,9 @@ main(int ac, const char* av[]) cout << "Cant cast " << (*network_info_timeout_opt) << " or/and " << (*mempool_info_timeout_opt) <<" into numbers. Using default values." << endl; - } + uint64_t mempool_refresh_time {10}; if (enable_emission_monitor == true) @@ -214,10 +216,24 @@ main(int ac, const char* av[]) xmreg::MempoolStatus::set_blockchain_variables( &mcore, core_storage); + + try + { + mempool_refresh_time = boost::lexical_cast(*mempool_refresh_time_opt); + + } + catch (boost::bad_lexical_cast &e) + { + cout << "Cant cast " << (*mempool_refresh_time_opt) + <<" into number. Using default value." + << endl; + } + // launch the status monitoring thread so that it keeps track of blockchain // info, e.g., current height. Information from this thread is used // by tx searching threads that are launched for each user independently, // when they log back or create new account. + xmreg::MempoolStatus::mempool_refresh_time = mempool_refresh_time; xmreg::MempoolStatus::start_mempool_status_thread(); // create instance of page class which diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp index db82f64..6ed921f 100644 --- a/src/CmdLineOptions.cpp +++ b/src/CmdLineOptions.cpp @@ -59,6 +59,8 @@ namespace xmreg "maximum time, in milliseconds, to wait for network info availability") ("mempool-info-timeout", value()->default_value("5000"), "maximum time, in milliseconds, to wait for mempool data for the front page") + ("mempool-refresh-time", value()->default_value("10"), + "time, in seconds, for each refresh of mempool state") ("bc-path,b", value(), "path to lmdb folder of the blockchain, e.g., ~/.bitmonero/lmdb") ("ssl-crt-file", value(), diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index 98746bb..9c7a4a3 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -34,12 +34,16 @@ MempoolStatus::start_mempool_status_thread() if (MempoolStatus::read_mempool()) { vector current_mempool_txs = get_mempool_txs(); - cout << "mempool status txs: " << current_mempool_txs.size() << endl; + + cout << "mempool status txs: " + << current_mempool_txs.size() + << endl; } // when we reach top of the blockchain, update // the emission amount every minute. - boost::this_thread::sleep_for(boost::chrono::seconds(10)); + boost::this_thread::sleep_for( + boost::chrono::seconds(mempool_refresh_time)); } // while (true) } @@ -159,5 +163,6 @@ xmreg::MicroCore* MempoolStatus::mcore {nullptr}; vector MempoolStatus::mempool_txs; atomic MempoolStatus::mempool_no {0}; // no of txs atomic MempoolStatus::mempool_size {0}; // size in bytes. +uint64_t MempoolStatus::mempool_refresh_time {10}; mutex MempoolStatus::mempool_mutx; } \ No newline at end of file diff --git a/src/MempoolStatus.h b/src/MempoolStatus.h index 6246483..9cc64c8 100644 --- a/src/MempoolStatus.h +++ b/src/MempoolStatus.h @@ -43,6 +43,8 @@ struct MempoolStatus static atomic is_running; + static uint64_t mempool_refresh_time; + static atomic mempool_no; // no of txs static atomic mempool_size; // size in bytes.