forked from lthn/blockchain
Add --disable-ntp parameter (#317)
* Add disable-ntp parameter * Also allow GUI to disable NTP * Update src/currency_protocol/currency_protocol_handler.inl Co-authored-by: crypto.sowle <crypto.sowle@gmail.com>
This commit is contained in:
parent
ca6c7e81e1
commit
6c7ee2590d
6 changed files with 14 additions and 0 deletions
|
|
@ -28,6 +28,7 @@ namespace command_line
|
|||
const arg_descriptor<bool> arg_show_rpc_autodoc = { "show_rpc_autodoc", "Display rpc auto-generated documentation template" };
|
||||
|
||||
const arg_descriptor<bool> arg_disable_upnp = { "disable-upnp", "Disable UPnP (enhances local network privacy)", false, true };
|
||||
const arg_descriptor<bool> arg_disable_ntp = { "disable-ntp", "Disable NTP, could enhance to time synchronization issue but increase network privacy, consider using disable-stop-if-time-out-of-sync with it", false, true };
|
||||
|
||||
const arg_descriptor<bool> arg_disable_stop_if_time_out_of_sync = { "disable-stop-if-time-out-of-sync", "Do not stop the daemon if serious time synchronization problem is detected", false, true };
|
||||
const arg_descriptor<bool> arg_disable_stop_on_low_free_space = { "disable-stop-on-low-free-space", "Do not stop the daemon if free space at data dir is critically low", false, true };
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ namespace command_line
|
|||
extern const arg_descriptor<bool> arg_show_details;
|
||||
extern const arg_descriptor<bool> arg_show_rpc_autodoc;
|
||||
extern const arg_descriptor<bool> arg_disable_upnp;
|
||||
extern const arg_descriptor<bool> arg_disable_ntp;
|
||||
extern const arg_descriptor<bool> arg_disable_stop_if_time_out_of_sync;
|
||||
extern const arg_descriptor<bool> arg_disable_stop_on_low_free_space;
|
||||
extern const arg_descriptor<bool> arg_enable_offers_service;
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ namespace currency
|
|||
int64_t m_last_median2local_time_difference;
|
||||
int64_t m_last_ntp2local_time_difference;
|
||||
uint32_t m_debug_ip_address;
|
||||
bool m_disable_ntp;
|
||||
|
||||
template<class t_parametr>
|
||||
bool post_notify(typename t_parametr::request& arg, currency_connection_context& context)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace currency
|
|||
, m_last_median2local_time_difference(0)
|
||||
, m_last_ntp2local_time_difference(0)
|
||||
, m_debug_ip_address(0)
|
||||
, m_disable_ntp(false)
|
||||
{
|
||||
if(!m_p2p)
|
||||
m_p2p = &m_p2p_stub;
|
||||
|
|
@ -38,6 +39,8 @@ namespace currency
|
|||
bool t_currency_protocol_handler<t_core>::init(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
m_relay_que_thread = std::thread([this](){relay_que_worker();});
|
||||
if (command_line::has_arg(vm, command_line::arg_disable_ntp))
|
||||
m_disable_ntp = command_line::get_arg(vm, command_line::arg_disable_ntp);
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
@ -834,6 +837,12 @@ namespace currency
|
|||
LOG_PRINT_MAGENTA("TIME: network time difference is " << m_last_median2local_time_difference << " (max is " << TIME_SYNC_DELTA_TO_LOCAL_MAX_DIFFERENCE << ")", ((m_last_median2local_time_difference >= 3) ? LOG_LEVEL_2 : LOG_LEVEL_3));
|
||||
if (std::abs(m_last_median2local_time_difference) > TIME_SYNC_DELTA_TO_LOCAL_MAX_DIFFERENCE)
|
||||
{
|
||||
// treat as error getting ntp time
|
||||
if (m_disable_ntp)
|
||||
{
|
||||
LOG_PRINT_RED("TIME: network time difference is " << m_last_median2local_time_difference << " (max is " << TIME_SYNC_DELTA_TO_LOCAL_MAX_DIFFERENCE << ") while NTP is disabled", LOG_LEVEL_0);
|
||||
return false;
|
||||
}
|
||||
int64_t ntp_time = tools::get_ntp_time();
|
||||
LOG_PRINT_L2("NTP: received time " << ntp_time << " (" << epee::misc_utils::get_time_str_v2(ntp_time) << "), diff: " << std::showpos << get_core_time() - ntp_time);
|
||||
if (ntp_time == 0)
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_cmd_sett, command_line::arg_force_predownload);
|
||||
command_line::add_arg(desc_cmd_sett, command_line::arg_validate_predownload);
|
||||
command_line::add_arg(desc_cmd_sett, command_line::arg_predownload_link);
|
||||
command_line::add_arg(desc_cmd_sett, command_line::arg_disable_ntp);
|
||||
|
||||
|
||||
arg_market_disable.default_value = true;
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ bool wallets_manager::init_command_line(int argc, char* argv[], std::string& fai
|
|||
command_line::add_arg(desc_cmd_sett, command_line::arg_validate_predownload);
|
||||
command_line::add_arg(desc_cmd_sett, command_line::arg_predownload_link);
|
||||
command_line::add_arg(desc_cmd_sett, command_line::arg_deeplink);
|
||||
command_line::add_arg(desc_cmd_sett, command_line::arg_disable_ntp);
|
||||
|
||||
|
||||
#ifndef MOBILE_WALLET_BUILD
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue