Log abnormal close time offsets (RIPD-572)

This commit is contained in:
Miguel Portilla
2015-01-15 18:57:48 -05:00
committed by Vinnie Falco
parent 8b848770dc
commit a9dfb33126
3 changed files with 36 additions and 9 deletions

View File

@@ -124,11 +124,15 @@ public:
// Our best estimate of current ledger close time // Our best estimate of current ledger close time
std::uint32_t getCloseTimeNC () const; std::uint32_t getCloseTimeNC () const;
std::uint32_t getCloseTimeNC (int& offset) const;
// Use *only* to timestamp our own validation // Use *only* to timestamp our own validation
std::uint32_t getValidationTimeNC (); std::uint32_t getValidationTimeNC ();
void closeTimeOffset (int); void closeTimeOffset (int);
boost::posix_time::ptime getNetworkTimePT () const;
/** On return the offset param holds the System time offset in seconds.
*/
boost::posix_time::ptime getNetworkTimePT(int& offset) const;
std::uint32_t getLedgerID (uint256 const& hash); std::uint32_t getLedgerID (uint256 const& hash);
std::uint32_t getCurrentLedgerID (); std::uint32_t getCurrentLedgerID ();
OperatingMode getOperatingMode () const OperatingMode getOperatingMode () const
@@ -762,12 +766,14 @@ std::string NetworkOPsImp::strOperatingMode () const
return paStatusToken[mMode]; return paStatusToken[mMode];
} }
boost::posix_time::ptime NetworkOPsImp::getNetworkTimePT () const boost::posix_time::ptime NetworkOPsImp::getNetworkTimePT (int& offset) const
{ {
int offset = 0; offset = 0;
getApp().getSystemTimeOffset (offset); getApp().getSystemTimeOffset (offset);
if (std::abs (offset) >= 60)
m_journal.warning << "Large system time offset (" << offset << ").";
// VFALCO TODO Replace this with a beast call // VFALCO TODO Replace this with a beast call
return boost::posix_time::microsec_clock::universal_time () + return boost::posix_time::microsec_clock::universal_time () +
boost::posix_time::seconds (offset); boost::posix_time::seconds (offset);
@@ -775,12 +781,20 @@ boost::posix_time::ptime NetworkOPsImp::getNetworkTimePT () const
std::uint32_t NetworkOPsImp::getNetworkTimeNC () const std::uint32_t NetworkOPsImp::getNetworkTimeNC () const
{ {
return iToSeconds (getNetworkTimePT ()); int offset;
return iToSeconds (getNetworkTimePT (offset));
} }
std::uint32_t NetworkOPsImp::getCloseTimeNC () const std::uint32_t NetworkOPsImp::getCloseTimeNC () const
{ {
return iToSeconds (getNetworkTimePT () + int offset;
return iToSeconds (getNetworkTimePT (offset) +
boost::posix_time::seconds (mCloseTimeOffset));
}
std::uint32_t NetworkOPsImp::getCloseTimeNC (int& offset) const
{
return iToSeconds (getNetworkTimePT (offset) +
boost::posix_time::seconds (mCloseTimeOffset)); boost::posix_time::seconds (mCloseTimeOffset));
} }
@@ -806,7 +820,12 @@ void NetworkOPsImp::closeTimeOffset (int offset)
mCloseTimeOffset = (mCloseTimeOffset * 3) / 4; mCloseTimeOffset = (mCloseTimeOffset * 3) / 4;
if (mCloseTimeOffset != 0) if (mCloseTimeOffset != 0)
{
m_journal.info << "Close time offset now " << mCloseTimeOffset; m_journal.info << "Close time offset now " << mCloseTimeOffset;
if (std::abs (mCloseTimeOffset) >= 60)
m_journal.warning << "Large close time offset (" << mCloseTimeOffset << ").";
}
} }
std::uint32_t NetworkOPsImp::getLedgerID (uint256 const& hash) std::uint32_t NetworkOPsImp::getLedgerID (uint256 const& hash)
@@ -2420,8 +2439,14 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
lpClosed->getReserveInc () * baseFee / baseRef)) lpClosed->getReserveInc () * baseFee / baseRef))
/ SYSTEM_CURRENCY_PARTS; / SYSTEM_CURRENCY_PARTS;
std::uint32_t closeTime = getCloseTimeNC (); int offset;
std::uint32_t lCloseTime = lpClosed->getCloseTimeNC (); std::uint32_t closeTime (getCloseTimeNC (offset));
if (std::abs (offset) >= 60)
l[jss::system_time_offset] = offset;
std::uint32_t lCloseTime (lpClosed->getCloseTimeNC ());
if (std::abs (mCloseTimeOffset) >= 60)
l[jss::close_time_offset] = mCloseTimeOffset;
if (lCloseTime <= closeTime) if (lCloseTime <= closeTime)
{ {

View File

@@ -109,7 +109,7 @@ public:
// Use *only* to timestamp our own validation // Use *only* to timestamp our own validation
virtual std::uint32_t getValidationTimeNC () = 0; virtual std::uint32_t getValidationTimeNC () = 0;
virtual void closeTimeOffset (int) = 0; virtual void closeTimeOffset (int) = 0;
virtual boost::posix_time::ptime getNetworkTimePT () const = 0; virtual boost::posix_time::ptime getNetworkTimePT (int& offset) const = 0;
virtual std::uint32_t getLedgerID (uint256 const& hash) = 0; virtual std::uint32_t getLedgerID (uint256 const& hash) = 0;
virtual std::uint32_t getCurrentLedgerID () = 0; virtual std::uint32_t getCurrentLedgerID () = 0;

View File

@@ -58,6 +58,7 @@ JSS ( closed_ledger );
JSS ( close_time ); JSS ( close_time );
JSS ( close_time_estimated ); JSS ( close_time_estimated );
JSS ( close_time_human ); JSS ( close_time_human );
JSS ( close_time_offset );
JSS ( close_time_resolution ); JSS ( close_time_resolution );
JSS ( code ); JSS ( code );
JSS ( command ); JSS ( command );
@@ -152,6 +153,7 @@ JSS ( server_status );
JSS ( stand_alone ); JSS ( stand_alone );
JSS ( status ); JSS ( status );
JSS ( success ); JSS ( success );
JSS ( system_time_offset );
JSS ( taker_gets ); JSS ( taker_gets );
JSS ( taker_gets_funded ); JSS ( taker_gets_funded );
JSS ( taker_pays ); JSS ( taker_pays );