mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-05 16:57:56 +00:00
Cleanups.
This commit is contained in:
@@ -86,7 +86,8 @@
|
||||
# 2001:0db8:0100:f101:0210:a4ff:fee3:9566
|
||||
#
|
||||
# [sntp_servers]
|
||||
# IP address or domain of servers to use for time synchronization.
|
||||
# IP address or domain of servers to use for time synchronization.
|
||||
# The default time servers are suitable for servers located in the United States
|
||||
#
|
||||
# [peer_ip]:
|
||||
# IP address or domain to bind to allow external connections from peers.
|
||||
@@ -145,8 +146,9 @@ debug.log
|
||||
|
||||
[sntp_servers]
|
||||
time.windows.com
|
||||
us.pool.ntp.org
|
||||
time.apple.com
|
||||
time.nist.gov
|
||||
pool.ntp.org
|
||||
|
||||
[validation_seed]
|
||||
shh1D4oj5czH3PUEjYES8c7Bay3tE
|
||||
|
||||
@@ -575,12 +575,14 @@ void Peer::recvHello(newcoin::TMHello& packet)
|
||||
uint32 minTime = ourTime - 10;
|
||||
uint32 maxTime = ourTime + 10;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (packet.has_nettime())
|
||||
{
|
||||
int64 to = ourTime;
|
||||
to -= packet.nettime();
|
||||
Log(lsTRACE) << "Connect: time error " << to;
|
||||
Log(lsDEBUG) << "Connect: time offset " << to;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (packet.has_nettime() && ((packet.nettime() < minTime) || (packet.nettime() > maxTime)))
|
||||
{
|
||||
|
||||
@@ -13,6 +13,9 @@ static uint8_t SNTPQueryData[48] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
// NTP query frequency - 5 minutes
|
||||
#define NTP_QUERY_FREQUENCY (5 * 60)
|
||||
|
||||
// NTP timestamp constant
|
||||
#define NTP_UNIX_OFFSET 0x83AA7E80
|
||||
|
||||
@@ -40,7 +43,7 @@ SNTPClient::SNTPClient(boost::asio::io_service& service) :
|
||||
boost::bind(&SNTPClient::receivePacket, this, boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred));
|
||||
|
||||
mTimer.expires_from_now(boost::posix_time::seconds(1));
|
||||
mTimer.expires_from_now(boost::posix_time::seconds(NTP_QUERY_FREQUENCY));
|
||||
mTimer.async_wait(boost::bind(&SNTPClient::timerEntry, this, boost::asio::placeholders::error));
|
||||
}
|
||||
|
||||
@@ -138,11 +141,13 @@ void SNTPClient::processReply()
|
||||
if ((timev == -1) || (timev == 1)) // small corrections likely do more harm than good
|
||||
timev = 0;
|
||||
|
||||
// FIXME: We really should use the median of all recent valid offsets
|
||||
if ((mLastOffsetUpdate == (time_t) -1) || (mLastOffsetUpdate < (now - 180)))
|
||||
mOffset = timev;
|
||||
else
|
||||
mOffset = ((mOffset * 7) + timev) / 8;
|
||||
mLastOffsetUpdate = now;
|
||||
|
||||
Log(lsTRACE) << "SNTP: Offset is " << timev << ", new system offset is " << mOffset;
|
||||
}
|
||||
|
||||
@@ -151,7 +156,7 @@ void SNTPClient::timerEntry(const boost::system::error_code& error)
|
||||
if (!error)
|
||||
{
|
||||
doQuery();
|
||||
mTimer.expires_from_now(boost::posix_time::seconds(10));
|
||||
mTimer.expires_from_now(boost::posix_time::seconds(NTP_QUERY_FREQUENCY));
|
||||
mTimer.async_wait(boost::bind(&SNTPClient::timerEntry, this, boost::asio::placeholders::error));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user