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