mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Ledger idle timing fixes.
This commit is contained in:
@@ -153,7 +153,7 @@ void Application::run()
|
||||
secondLedger->setAccepted();
|
||||
mMasterLedger.pushLedger(secondLedger, boost::make_shared<Ledger>(true, boost::ref(*secondLedger)));
|
||||
assert(!!secondLedger->getAccountState(rootAddress));
|
||||
mNetOps.setLastCloseNetTime(secondLedger->getCloseTimeNC());
|
||||
mNetOps.setLastCloseTime(secondLedger->getCloseTimeNC());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -421,21 +421,32 @@ void LedgerConsensus::statePreClose()
|
||||
int proposersClosed = mPeerPositions.size();
|
||||
|
||||
// This ledger is open. This computes how long since the last ledger closed
|
||||
int lastCloseTime;
|
||||
if (!anyTransactions && mPreviousLedger->getCloseAgree())
|
||||
uint32 lastCloseTime;
|
||||
int ledgerInterval = 0;
|
||||
|
||||
if (mHaveCorrectLCL && mPreviousLedger->getCloseAgree())
|
||||
{ // we can use consensus timing
|
||||
lastCloseTime = mPreviousLedger->getCloseTimeNC();
|
||||
ledgerInterval = 2 * mPreviousLedger->getCloseResolution();
|
||||
if (ledgerInterval < LEDGER_IDLE_INTERVAL)
|
||||
ledgerInterval = LEDGER_IDLE_INTERVAL;
|
||||
}
|
||||
else
|
||||
lastCloseTime = theApp->getOPs().getLastCloseNetTime();
|
||||
{
|
||||
lastCloseTime = theApp->getOPs().getLastCloseTime();
|
||||
ledgerInterval = LEDGER_IDLE_INTERVAL;
|
||||
}
|
||||
|
||||
int sinceClose = 1000 * (theApp->getOPs().getCloseTimeNC() - lastCloseTime);
|
||||
|
||||
if (sinceClose >= ContinuousLedgerTiming::shouldClose(anyTransactions, mPreviousProposers, proposersClosed,
|
||||
mPreviousMSeconds, sinceClose))
|
||||
mPreviousMSeconds, sinceClose, ledgerInterval))
|
||||
{ // it is time to close the ledger
|
||||
Log(lsINFO) << "CLC: closing ledger";
|
||||
mState = lcsESTABLISH;
|
||||
mConsensusStartTime = boost::posix_time::microsec_clock::universal_time();
|
||||
mCloseTime = theApp->getOPs().getCloseTimeNC();
|
||||
theApp->getOPs().setLastCloseNetTime(mCloseTime);
|
||||
theApp->getOPs().setLastCloseTime(mCloseTime);
|
||||
statusChange(newcoin::neCLOSING_LEDGER, *mPreviousLedger);
|
||||
takeInitialPosition(*theApp->getMasterLedger().closeLedger());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ int ContinuousLedgerTiming::shouldClose(
|
||||
int previousProposers, // proposers in the last closing
|
||||
int proposersClosed, // proposers who have currently closed this ledgers
|
||||
int previousMSeconds, // seconds the previous ledger took to reach consensus
|
||||
int currentMSeconds) // seconds since the previous ledger closed
|
||||
int currentMSeconds, // seconds since the previous ledger closed
|
||||
int idleInterval) // network's desired idle interval
|
||||
{
|
||||
if ((previousMSeconds < -1000) || (previousMSeconds > 600000) ||
|
||||
(currentMSeconds < -1000) || (currentMSeconds > 600000))
|
||||
@@ -44,7 +45,7 @@ int ContinuousLedgerTiming::shouldClose(
|
||||
return previousMSeconds;
|
||||
return previousMSeconds - 1000;
|
||||
}
|
||||
return LEDGER_IDLE_INTERVAL * 1000; // normal idle
|
||||
return idleInterval * 1000; // normal idle
|
||||
}
|
||||
|
||||
Log(lsTRACE) << "close now";
|
||||
|
||||
@@ -49,7 +49,8 @@ public:
|
||||
static int shouldClose(
|
||||
bool anyTransactions,
|
||||
int previousProposers, int proposersClosed,
|
||||
int previousSeconds, int currentSeconds);
|
||||
int previousSeconds, int currentSeconds,
|
||||
int idleInterval);
|
||||
|
||||
static bool haveConsensus(
|
||||
int previousProposers, int currentProposers,
|
||||
|
||||
@@ -63,7 +63,7 @@ protected:
|
||||
// last ledger close
|
||||
int mLastCloseProposers, mLastCloseConvergeTime;
|
||||
uint256 mLastCloseHash;
|
||||
uint32 mLastCloseNetTime;
|
||||
uint32 mLastCloseTime;
|
||||
|
||||
// XXX Split into more locks.
|
||||
boost::interprocess::interprocess_upgradable_mutex mMonitorLock;
|
||||
@@ -179,8 +179,8 @@ public:
|
||||
void newLCL(int proposers, int convergeTime, const uint256& ledgerHash);
|
||||
int getPreviousProposers() { return mLastCloseProposers; }
|
||||
int getPreviousConvergeTime() { return mLastCloseConvergeTime; }
|
||||
uint32 getLastCloseNetTime() { return mLastCloseNetTime; }
|
||||
void setLastCloseNetTime(uint32 t) { mLastCloseNetTime = t; }
|
||||
uint32 getLastCloseTime() { return mLastCloseTime; }
|
||||
void setLastCloseTime(uint32 t) { mLastCloseTime = t; }
|
||||
Json::Value getServerInfo();
|
||||
|
||||
// client information retrieval functions
|
||||
|
||||
Reference in New Issue
Block a user