mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Separate close times and network times.
This commit is contained in:
@@ -71,7 +71,7 @@ Ledger::Ledger(bool dummy, Ledger& prevLedger) :
|
||||
prevLedger.getCloseAgree(), mLedgerSeq);
|
||||
if (prevLedger.mCloseTime == 0)
|
||||
{
|
||||
mCloseTime = theApp->getOPs().getNetworkTimeNC();
|
||||
mCloseTime = theApp->getOPs().getCloseTimeNC();
|
||||
mCloseTime -= (mCloseTime % mCloseResolution);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -404,7 +404,7 @@ void LedgerConsensus::statePreClose()
|
||||
int proposersClosed = mPeerPositions.size();
|
||||
|
||||
// This ledger is open. This computes how long since the last ledger closed
|
||||
int sinceClose = 1000 * (theApp->getOPs().getNetworkTimeNC() - theApp->getOPs().getLastCloseNetTime());
|
||||
int sinceClose = 1000 * (theApp->getOPs().getCloseTimeNC() - theApp->getOPs().getLastCloseNetTime());
|
||||
|
||||
if (sinceClose >= ContinuousLedgerTiming::shouldClose(anyTransactions, mPreviousProposers, proposersClosed,
|
||||
mPreviousMSeconds, sinceClose))
|
||||
@@ -412,7 +412,7 @@ void LedgerConsensus::statePreClose()
|
||||
Log(lsINFO) << "CLC: closing ledger";
|
||||
mState = lcsESTABLISH;
|
||||
mConsensusStartTime = boost::posix_time::second_clock::universal_time();
|
||||
mCloseTime = theApp->getOPs().getNetworkTimeNC();
|
||||
mCloseTime = theApp->getOPs().getCloseTimeNC();
|
||||
theApp->getOPs().setLastCloseNetTime(mCloseTime);
|
||||
statusChange(newcoin::neCLOSING_LEDGER, *mPreviousLedger);
|
||||
takeInitialPosition(*theApp->getMasterLedger().closeLedger());
|
||||
@@ -930,7 +930,7 @@ void LedgerConsensus::accept(SHAMap::pointer set)
|
||||
closeTotal += (closeCount / 2);
|
||||
closeTotal /= closeCount;
|
||||
int offset = static_cast<int>(closeTotal) - static_cast<int>(mCloseTime);
|
||||
Log(lsINFO) << "Our clock offset is estimated at " << offset;
|
||||
Log(lsINFO) << "Our close offset is estimated at " << offset << " (" << closeCount << ")";
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# define LEDGER_IDLE_INTERVAL 15
|
||||
|
||||
// The number of seconds a validation remains current
|
||||
# define LEDGER_MAX_INTERVAL 60
|
||||
# define LEDGER_MAX_INTERVAL (LEDGER_IDLE_INTERVAL * 4)
|
||||
|
||||
// The number of milliseconds we wait minimum to ensure participation
|
||||
# define LEDGER_MIN_CONSENSUS 2000
|
||||
|
||||
@@ -24,18 +24,15 @@
|
||||
// there's a functional network.
|
||||
|
||||
NetworkOPs::NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster) :
|
||||
mMode(omDISCONNECTED),mNetTimer(io_service), mLedgerMaster(pLedgerMaster), mTimeOffset(0),
|
||||
mMode(omDISCONNECTED),mNetTimer(io_service), mLedgerMaster(pLedgerMaster), mCloseTimeOffset(0),
|
||||
mLastCloseProposers(0), mLastCloseConvergeTime(LEDGER_IDLE_INTERVAL)
|
||||
{
|
||||
}
|
||||
|
||||
boost::posix_time::ptime NetworkOPs::getNetworkTimePT()
|
||||
{
|
||||
int offset;
|
||||
if (theApp->getSystemTimeOffset(offset))
|
||||
offset += mTimeOffset;
|
||||
else
|
||||
offset = mTimeOffset;
|
||||
int offset = 0;
|
||||
theApp->getSystemTimeOffset(offset);
|
||||
return boost::posix_time::second_clock::universal_time() + boost::posix_time::seconds(offset);
|
||||
}
|
||||
|
||||
@@ -44,6 +41,11 @@ uint32 NetworkOPs::getNetworkTimeNC()
|
||||
return iToSeconds(getNetworkTimePT());
|
||||
}
|
||||
|
||||
uint32 NetworkOPs::getCloseTimeNC()
|
||||
{
|
||||
return iToSeconds(getNetworkTimePT() + boost::posix_time::seconds(mCloseTimeOffset));
|
||||
}
|
||||
|
||||
uint32 NetworkOPs::getCurrentLedgerID()
|
||||
{
|
||||
return mLedgerMaster->getCurrentLedger()->getLedgerSeq();
|
||||
|
||||
@@ -58,7 +58,7 @@ protected:
|
||||
LedgerMaster* mLedgerMaster;
|
||||
LedgerAcquire::pointer mAcquiringLedger;
|
||||
|
||||
int mTimeOffset;
|
||||
int mCloseTimeOffset;
|
||||
|
||||
// last ledger close
|
||||
int mLastCloseProposers, mLastCloseConvergeTime;
|
||||
@@ -88,6 +88,7 @@ public:
|
||||
|
||||
// network information
|
||||
uint32 getNetworkTimeNC();
|
||||
uint32 getCloseTimeNC();
|
||||
boost::posix_time::ptime getNetworkTimePT();
|
||||
uint32 getCurrentLedgerID();
|
||||
OperatingMode getOperatingMode() { return mMode; }
|
||||
|
||||
@@ -12,7 +12,7 @@ bool ValidationCollection::addValidation(SerializedValidation::pointer val)
|
||||
if (theApp->getUNL().nodeInUNL(signer))
|
||||
{
|
||||
val->setTrusted();
|
||||
uint32 now = theApp->getOPs().getNetworkTimeNC();
|
||||
uint32 now = theApp->getOPs().getCloseTimeNC();
|
||||
uint32 valClose = val->getCloseTime();
|
||||
if ((now > valClose) && (now < (valClose + LEDGER_MAX_INTERVAL)))
|
||||
isCurrent = true;
|
||||
@@ -72,7 +72,7 @@ void ValidationCollection::getValidationCount(const uint256& ledger, bool curren
|
||||
trusted = untrusted = 0;
|
||||
boost::mutex::scoped_lock sl(mValidationLock);
|
||||
boost::unordered_map<uint256, ValidationSet>::iterator it = mValidations.find(ledger);
|
||||
uint32 now = theApp->getOPs().getNetworkTimeNC();
|
||||
uint32 now = theApp->getOPs().getCloseTimeNC();
|
||||
if (it != mValidations.end())
|
||||
{
|
||||
for (ValidationSet::iterator vit = it->second.begin(), end = it->second.end(); vit != end; ++vit)
|
||||
@@ -123,7 +123,7 @@ int ValidationCollection::getCurrentValidationCount(uint32 afterTime)
|
||||
|
||||
boost::unordered_map<uint256, int> ValidationCollection::getCurrentValidations()
|
||||
{
|
||||
uint32 now = theApp->getOPs().getNetworkTimeNC();
|
||||
uint32 now = theApp->getOPs().getCloseTimeNC();
|
||||
boost::unordered_map<uint256, int> ret;
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user