mempool and network info timeout parameters added

master
moneroexamples 8 years ago
parent 74d5b90405
commit c9ee47ec3c

@ -186,6 +186,10 @@ xmrblocks, Onion Monero Blockchain Explorer:
page to mainnet explorer
--no-blocks-on-index arg (=10) number of last blocks to be shown on
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,
e.g., ~/.bitmonero/lmdb
--ssl-crt-file arg path to crt file for ssl (https)

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

@ -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")
("no-blocks-on-index", value<string>()->default_value("10"),
"number of last blocks to be shown on index page")
("network-info-timeout", value<string>()->default_value("3000"),
"maximum time, in milliseconds, to wait for mempool data availability")
("network-info-timeout", value<string>()->default_value("1000"),
"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>(),
"path to lmdb folder of the blockchain, e.g., ~/.bitmonero/lmdb")
("ssl-crt-file", value<string>(),

@ -263,6 +263,7 @@ namespace xmreg
uint64_t no_of_mempool_tx_of_frontpage;
uint64_t no_blocks_on_index;
uint64_t network_info_timeout;
uint64_t mempool_info_timeout;
string testnet_url;
string mainnet_url;
@ -353,6 +354,7 @@ namespace xmreg
bool _show_cache_times,
uint64_t _no_blocks_on_index,
uint64_t _network_info_timeout,
uint64_t _mempool_info_timeout,
string _testnet_url,
string _mainnet_url)
: mcore {_mcore},
@ -371,6 +373,7 @@ namespace xmreg
show_cache_times {_show_cache_times},
no_blocks_on_index {_no_blocks_on_index},
network_info_timeout {_network_info_timeout},
mempool_info_timeout {_mempool_info_timeout},
testnet_url {_testnet_url},
mainnet_url {_mainnet_url},
mempool_tx_json_cache(1000),
@ -769,7 +772,7 @@ namespace xmreg
// if its not ready by now, forget about it.
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};
@ -838,7 +841,7 @@ namespace xmreg
// 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::chrono::milliseconds(network_info_timeout));
std::chrono::milliseconds(mempool_info_timeout));
if (mempool_ftr_status == std::future_status::ready)
{

Loading…
Cancel
Save