mempool-refresh-time option added

master
moneroexamples 8 years ago
parent 5a2489c05e
commit 093afee5ac

@ -51,6 +51,7 @@ main(int ac, const char* av[])
auto mainnet_url = opts.get_option<string>("mainnet-url"); auto mainnet_url = opts.get_option<string>("mainnet-url");
auto network_info_timeout_opt = opts.get_option<string>("network-info-timeout"); auto network_info_timeout_opt = opts.get_option<string>("network-info-timeout");
auto mempool_info_timeout_opt = opts.get_option<string>("mempool-info-timeout"); auto mempool_info_timeout_opt = opts.get_option<string>("mempool-info-timeout");
auto mempool_refresh_time_opt = opts.get_option<string>("mempool-refresh-time");
auto testnet_opt = opts.get_option<bool>("testnet"); auto testnet_opt = opts.get_option<bool>("testnet");
auto enable_key_image_checker_opt = opts.get_option<bool>("enable-key-image-checker"); auto enable_key_image_checker_opt = opts.get_option<bool>("enable-key-image-checker");
auto enable_output_key_checker_opt = opts.get_option<bool>("enable-output-key-checker"); auto enable_output_key_checker_opt = opts.get_option<bool>("enable-output-key-checker");
@ -157,6 +158,7 @@ main(int ac, const char* av[])
uint64_t network_info_timeout {1000}; uint64_t network_info_timeout {1000};
uint64_t mempool_info_timeout {5000}; uint64_t mempool_info_timeout {5000};
try try
{ {
network_info_timeout = boost::lexical_cast<uint64_t>(*network_info_timeout_opt); network_info_timeout = boost::lexical_cast<uint64_t>(*network_info_timeout_opt);
@ -168,9 +170,9 @@ main(int ac, const char* av[])
cout << "Cant cast " << (*network_info_timeout_opt) cout << "Cant cast " << (*network_info_timeout_opt)
<< " or/and " << (*mempool_info_timeout_opt) <<" into numbers. Using default values." << " or/and " << (*mempool_info_timeout_opt) <<" into numbers. Using default values."
<< endl; << endl;
} }
uint64_t mempool_refresh_time {10};
if (enable_emission_monitor == true) if (enable_emission_monitor == true)
@ -214,10 +216,24 @@ main(int ac, const char* av[])
xmreg::MempoolStatus::set_blockchain_variables( xmreg::MempoolStatus::set_blockchain_variables(
&mcore, core_storage); &mcore, core_storage);
try
{
mempool_refresh_time = boost::lexical_cast<uint64_t>(*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 // launch the status monitoring thread so that it keeps track of blockchain
// info, e.g., current height. Information from this thread is used // info, e.g., current height. Information from this thread is used
// by tx searching threads that are launched for each user independently, // by tx searching threads that are launched for each user independently,
// when they log back or create new account. // when they log back or create new account.
xmreg::MempoolStatus::mempool_refresh_time = mempool_refresh_time;
xmreg::MempoolStatus::start_mempool_status_thread(); xmreg::MempoolStatus::start_mempool_status_thread();
// create instance of page class which // create instance of page class which

@ -59,6 +59,8 @@ namespace xmreg
"maximum time, in milliseconds, to wait for network info availability") "maximum time, in milliseconds, to wait for network info availability")
("mempool-info-timeout", value<string>()->default_value("5000"), ("mempool-info-timeout", value<string>()->default_value("5000"),
"maximum time, in milliseconds, to wait for mempool data for the front page") "maximum time, in milliseconds, to wait for mempool data for the front page")
("mempool-refresh-time", value<string>()->default_value("10"),
"time, in seconds, for each refresh of mempool state")
("bc-path,b", value<string>(), ("bc-path,b", value<string>(),
"path to lmdb folder of the blockchain, e.g., ~/.bitmonero/lmdb") "path to lmdb folder of the blockchain, e.g., ~/.bitmonero/lmdb")
("ssl-crt-file", value<string>(), ("ssl-crt-file", value<string>(),

@ -34,12 +34,16 @@ MempoolStatus::start_mempool_status_thread()
if (MempoolStatus::read_mempool()) if (MempoolStatus::read_mempool())
{ {
vector<mempool_tx> current_mempool_txs = get_mempool_txs(); vector<mempool_tx> 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 // when we reach top of the blockchain, update
// the emission amount every minute. // 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) } // while (true)
} }
@ -159,5 +163,6 @@ xmreg::MicroCore* MempoolStatus::mcore {nullptr};
vector<MempoolStatus::mempool_tx> MempoolStatus::mempool_txs; vector<MempoolStatus::mempool_tx> MempoolStatus::mempool_txs;
atomic<uint64_t> MempoolStatus::mempool_no {0}; // no of txs atomic<uint64_t> MempoolStatus::mempool_no {0}; // no of txs
atomic<uint64_t> MempoolStatus::mempool_size {0}; // size in bytes. atomic<uint64_t> MempoolStatus::mempool_size {0}; // size in bytes.
uint64_t MempoolStatus::mempool_refresh_time {10};
mutex MempoolStatus::mempool_mutx; mutex MempoolStatus::mempool_mutx;
} }

@ -43,6 +43,8 @@ struct MempoolStatus
static atomic<bool> is_running; static atomic<bool> is_running;
static uint64_t mempool_refresh_time;
static atomic<uint64_t> mempool_no; // no of txs static atomic<uint64_t> mempool_no; // no of txs
static atomic<uint64_t> mempool_size; // size in bytes. static atomic<uint64_t> mempool_size; // size in bytes.

Loading…
Cancel
Save