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
std::uint32_t getCloseTimeNC () const;
std::uint32_t getCloseTimeNC (int& offset) const;
// Use *only* to timestamp our own validation
std::uint32_t getValidationTimeNC ();
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 getCurrentLedgerID ();
OperatingMode getOperatingMode () const
@@ -762,12 +766,14 @@ std::string NetworkOPsImp::strOperatingMode () const
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);
if (std::abs (offset) >= 60)
m_journal.warning << "Large system time offset (" << offset << ").";
// VFALCO TODO Replace this with a beast call
return boost::posix_time::microsec_clock::universal_time () +
boost::posix_time::seconds (offset);
@@ -775,12 +781,20 @@ boost::posix_time::ptime NetworkOPsImp::getNetworkTimePT () const
std::uint32_t NetworkOPsImp::getNetworkTimeNC () const
{
return iToSeconds (getNetworkTimePT ());
int offset;
return iToSeconds (getNetworkTimePT (offset));
}
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));
}
@@ -806,7 +820,12 @@ void NetworkOPsImp::closeTimeOffset (int offset)
mCloseTimeOffset = (mCloseTimeOffset * 3) / 4;
if (mCloseTimeOffset != 0)
{
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)
@@ -2420,8 +2439,14 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
lpClosed->getReserveInc () * baseFee / baseRef))
/ SYSTEM_CURRENCY_PARTS;
std::uint32_t closeTime = getCloseTimeNC ();
std::uint32_t lCloseTime = lpClosed->getCloseTimeNC ();
int offset;
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)
{

View File

@@ -109,7 +109,7 @@ public:
// Use *only* to timestamp our own validation
virtual std::uint32_t getValidationTimeNC () = 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 getCurrentLedgerID () = 0;

View File

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