diff --git a/README.md b/README.md index b83806f..bbc5a73 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/main.cpp b/main.cpp index 1c8275e..aa48895 100644 --- a/main.cpp +++ b/main.cpp @@ -50,6 +50,7 @@ main(int ac, const char* av[]) auto testnet_url = opts.get_option("testnet-url"); 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 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"); @@ -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(*network_info_timeout_opt); + mempool_info_timeout = boost::lexical_cast(*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); diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp index 83cac7c..082e95a 100644 --- a/src/CmdLineOptions.cpp +++ b/src/CmdLineOptions.cpp @@ -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()->default_value("10"), "number of last blocks to be shown on index page") - ("network-info-timeout", value()->default_value("3000"), - "maximum time, in milliseconds, to wait for mempool data availability") + ("network-info-timeout", value()->default_value("1000"), + "maximum time, in milliseconds, to wait for network info availability") + ("mempool-info-timeout", value()->default_value("1000"), + "maximum time, in milliseconds, to wait for mempool data for the front page") ("bc-path,b", value(), "path to lmdb folder of the blockchain, e.g., ~/.bitmonero/lmdb") ("ssl-crt-file", value(), diff --git a/src/page.h b/src/page.h index 54e28ea..3b45186 100644 --- a/src/page.h +++ b/src/page.h @@ -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) {