mempool and network info timeout parameters added

This commit is contained in:
moneroexamples 2017-05-28 09:10:42 +08:00
parent 74d5b90405
commit c9ee47ec3c
4 changed files with 21 additions and 8 deletions

View File

@ -186,6 +186,10 @@ xmrblocks, Onion Monero Blockchain Explorer:
page to mainnet explorer page to mainnet explorer
--no-blocks-on-index arg (=10) number of last blocks to be shown on --no-blocks-on-index arg (=10) number of last blocks to be shown on
index page index page
--network-info-timeout arg (=1000) maximum time, in milliseconds, to wait
for network info availability
--mempool-info-timeout arg (=1000) maximum time, in milliseconds, to wait
for mempool data for the front page
-b [ --bc-path ] arg path to lmdb folder of the blockchain, -b [ --bc-path ] arg path to lmdb folder of the blockchain,
e.g., ~/.bitmonero/lmdb e.g., ~/.bitmonero/lmdb
--ssl-crt-file arg path to crt file for ssl (https) --ssl-crt-file arg path to crt file for ssl (https)

View File

@ -50,6 +50,7 @@ main(int ac, const char* av[])
auto testnet_url = opts.get_option<string>("testnet-url"); auto testnet_url = opts.get_option<string>("testnet-url");
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 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");
@ -154,16 +155,18 @@ main(int ac, const char* av[])
deamon_url = "http:://127.0.0.1:28081"; deamon_url = "http:://127.0.0.1:28081";
} }
uint64_t network_info_timeout {3000}; uint64_t network_info_timeout {1000};
uint64_t mempool_info_timeout {3000};
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);
mempool_info_timeout = boost::lexical_cast<uint64_t>(*mempool_info_timeout_opt);
} }
catch (boost::bad_lexical_cast &e) catch (boost::bad_lexical_cast &e)
{ {
cout << "Cant cast " << (*network_info_timeout_opt) << " into number." cout << "Cant cast " << (*network_info_timeout_opt)
<< "Using default value of " << network_info_timeout << " milliseconds." << " or/and " << (*mempool_info_timeout_opt) <<" into numbers. Using default values."
<< endl; << endl;
} }
@ -218,6 +221,7 @@ main(int ac, const char* av[])
show_cache_times, show_cache_times,
no_blocks_on_index, no_blocks_on_index,
network_info_timeout, network_info_timeout,
mempool_info_timeout,
*testnet_url, *testnet_url,
*mainnet_url); *mainnet_url);

View File

@ -55,8 +55,10 @@ namespace xmreg
"you can specify 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")
("network-info-timeout", value<string>()->default_value("3000"), ("network-info-timeout", value<string>()->default_value("1000"),
"maximum time, in milliseconds, to wait for mempool data availability") "maximum time, in milliseconds, to wait for network info availability")
("mempool-info-timeout", value<string>()->default_value("1000"),
"maximum time, in milliseconds, to wait for mempool data for the front page")
("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>(),

View File

@ -263,6 +263,7 @@ namespace xmreg
uint64_t no_of_mempool_tx_of_frontpage; uint64_t no_of_mempool_tx_of_frontpage;
uint64_t no_blocks_on_index; uint64_t no_blocks_on_index;
uint64_t network_info_timeout; uint64_t network_info_timeout;
uint64_t mempool_info_timeout;
string testnet_url; string testnet_url;
string mainnet_url; string mainnet_url;
@ -353,6 +354,7 @@ namespace xmreg
bool _show_cache_times, bool _show_cache_times,
uint64_t _no_blocks_on_index, uint64_t _no_blocks_on_index,
uint64_t _network_info_timeout, uint64_t _network_info_timeout,
uint64_t _mempool_info_timeout,
string _testnet_url, string _testnet_url,
string _mainnet_url) string _mainnet_url)
: mcore {_mcore}, : mcore {_mcore},
@ -371,6 +373,7 @@ namespace xmreg
show_cache_times {_show_cache_times}, show_cache_times {_show_cache_times},
no_blocks_on_index {_no_blocks_on_index}, no_blocks_on_index {_no_blocks_on_index},
network_info_timeout {_network_info_timeout}, network_info_timeout {_network_info_timeout},
mempool_info_timeout {_mempool_info_timeout},
testnet_url {_testnet_url}, testnet_url {_testnet_url},
mainnet_url {_mainnet_url}, mainnet_url {_mainnet_url},
mempool_tx_json_cache(1000), mempool_tx_json_cache(1000),
@ -769,7 +772,7 @@ namespace xmreg
// if its not ready by now, forget about it. // if its not ready by now, forget about it.
std::future_status ftr_status = network_info_ftr.wait_for( std::future_status ftr_status = network_info_ftr.wait_for(
std::chrono::milliseconds(200)); std::chrono::milliseconds(network_info_timeout));
network_info current_network_info {0, 0, 0, 0, 0, 0}; network_info current_network_info {0, 0, 0, 0, 0, 0};
@ -838,7 +841,7 @@ namespace xmreg
// get mempool data for the front page, if ready. If not, then just skip. // get mempool data for the front page, if ready. If not, then just skip.
std::future_status mempool_ftr_status = mempool_ftr.wait_for( std::future_status mempool_ftr_status = mempool_ftr.wait_for(
std::chrono::milliseconds(network_info_timeout)); std::chrono::milliseconds(mempool_info_timeout));
if (mempool_ftr_status == std::future_status::ready) if (mempool_ftr_status == std::future_status::ready)
{ {