mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 05:25:55 +00:00
Remove pending save logic. Replace with job count logic.
Prioritize newer ledgers over clients.
This commit is contained in:
@@ -517,12 +517,12 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus)
|
||||
|
||||
if (!fromConsensus)
|
||||
{
|
||||
decPendingSaves();
|
||||
dropCache();
|
||||
return;
|
||||
}
|
||||
|
||||
decPendingSaves();
|
||||
if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) == 0)
|
||||
theApp->getLedgerMaster().resumeAcquiring();
|
||||
}
|
||||
|
||||
#ifndef NO_SQLITE3_PREPARE
|
||||
@@ -1501,15 +1501,6 @@ void Ledger::updateSkipList()
|
||||
}
|
||||
}
|
||||
|
||||
int Ledger::sPendingSaves = 0;
|
||||
boost::recursive_mutex Ledger::sPendingSaveLock;
|
||||
|
||||
int Ledger::getPendingSaves()
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(sPendingSaveLock);
|
||||
return sPendingSaves;
|
||||
}
|
||||
|
||||
uint32 Ledger::roundCloseTime(uint32 closeTime, uint32 closeResolution)
|
||||
{
|
||||
if (closeTime == 0)
|
||||
@@ -1524,27 +1515,12 @@ void Ledger::pendSave(bool fromConsensus)
|
||||
return;
|
||||
assert(isImmutable());
|
||||
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(sPendingSaveLock);
|
||||
++sPendingSaves;
|
||||
}
|
||||
|
||||
theApp->getJobQueue().addJob(jtPUBOLDLEDGER, "Ledger::pendSave", // FIXME not old if fromConsensus
|
||||
theApp->getJobQueue().addJob(fromconsensus ? jtPUBLEDGER : jtPUBOLDLEDGER,
|
||||
fromConsensus ? "Ledger::pendSave" : "Ledger::pendOldSave",
|
||||
boost::bind(&Ledger::saveAcceptedLedger, shared_from_this(), _1, fromConsensus));
|
||||
|
||||
}
|
||||
|
||||
void Ledger::decPendingSaves()
|
||||
{
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(sPendingSaveLock);
|
||||
--sPendingSaves;
|
||||
if (sPendingSaves != 0)
|
||||
return;
|
||||
}
|
||||
theApp->getLedgerMaster().resumeAcquiring();
|
||||
}
|
||||
|
||||
void Ledger::ownerDirDescriber(SLE::ref sle, const uint160& owner)
|
||||
{
|
||||
sle->setFieldAccount(sfOwner, owner);
|
||||
|
||||
@@ -89,9 +89,6 @@ private:
|
||||
|
||||
mutable boost::recursive_mutex mLock;
|
||||
|
||||
static int sPendingSaves;
|
||||
static boost::recursive_mutex sPendingSaveLock;
|
||||
|
||||
Ledger(const Ledger&); // no implementation
|
||||
Ledger& operator=(const Ledger&); // no implementation
|
||||
|
||||
@@ -101,8 +98,6 @@ protected:
|
||||
// returned SLE is immutable
|
||||
SLE::pointer getASNodeI(const uint256& nodeID, LedgerEntryType let);
|
||||
|
||||
static void incPendingSaves();
|
||||
static void decPendingSaves();
|
||||
void saveAcceptedLedger(Job&, bool fromConsensus);
|
||||
|
||||
void updateFees();
|
||||
@@ -126,7 +121,6 @@ public:
|
||||
static Ledger::pointer getSQL1(SqliteStatement*);
|
||||
static void getSQL2(Ledger::ref);
|
||||
static Ledger::pointer getLastFullLedger();
|
||||
static int getPendingSaves();
|
||||
static uint32 roundCloseTime(uint32 closeTime, uint32 closeResolution);
|
||||
|
||||
void updateHash();
|
||||
|
||||
@@ -388,7 +388,7 @@ void LedgerMaster::setFullLedger(Ledger::ref ledger)
|
||||
return;
|
||||
}
|
||||
|
||||
if (Ledger::getPendingSaves() > 2)
|
||||
if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) > 2)
|
||||
{
|
||||
mTooFast = true;
|
||||
cLog(lsDEBUG) << "Too many pending ledger saves";
|
||||
|
||||
Reference in New Issue
Block a user