mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Shed load if the ledger publication engine is falling behind.
This commit is contained in:
@@ -25,6 +25,7 @@ Ledger::ref LedgerMaster::getCurrentSnapshot ()
|
||||
|
||||
int LedgerMaster::getValidatedLedgerAge ()
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock ml (mLock);
|
||||
if (!mValidLedger)
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerMaster) << "No validated ledger";
|
||||
@@ -39,6 +40,27 @@ int LedgerMaster::getValidatedLedgerAge ()
|
||||
return static_cast<int> (ret);
|
||||
}
|
||||
|
||||
bool LedgerMaster::isCaughtUp(std::string& reason)
|
||||
{
|
||||
if (getValidatedLedgerAge() > 180)
|
||||
{
|
||||
reason = "No recently-validated ledger";
|
||||
return false;
|
||||
}
|
||||
boost::recursive_mutex::scoped_lock ml (mLock);
|
||||
if (!mValidLedger || !mPubLedger)
|
||||
{
|
||||
reason = "No published ledger";
|
||||
return false;
|
||||
}
|
||||
if (mValidLedger->getLedgerSeq() > (mPubLedger->getLedgerSeq() + 3))
|
||||
{
|
||||
reason = "Published ledger lags validated ledger";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void LedgerMaster::addHeldTransaction (Transaction::ref transaction)
|
||||
{
|
||||
// returns true if transaction was added
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
return mPubLedger;
|
||||
}
|
||||
int getValidatedLedgerAge ();
|
||||
bool isCaughtUp(std::string& reason);
|
||||
|
||||
TER doTransaction (SerializedTransaction::ref txn, TransactionEngineParams params, bool& didApply);
|
||||
|
||||
|
||||
@@ -829,6 +829,9 @@ bool serverOkay (std::string& reason)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!theApp->getLedgerMaster().isCaughtUp(reason))
|
||||
return false;
|
||||
|
||||
if (theApp->getFeeTrack ().isLoaded ())
|
||||
{
|
||||
reason = "Too much load";
|
||||
|
||||
@@ -201,6 +201,8 @@ private:
|
||||
|
||||
// We do it this way in case we want to add exponential decay later
|
||||
int now = UptimeTimer::getInstance ().getElapsedSeconds ();
|
||||
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
canonicalize (source, now);
|
||||
source.mBalance += credits;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user