mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Don't let ledger fetching go too fast.
This commit is contained in:
@@ -118,6 +118,14 @@ int JobQueue::getJobCount(JobType t)
|
|||||||
return (c == mJobCounts.end()) ? 0 : c->second.first;
|
return (c == mJobCounts.end()) ? 0 : c->second.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int JobQueue::getJobCountTotal(JobType t)
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock sl(mJobLock);
|
||||||
|
|
||||||
|
std::map< JobType, std::pair<int, int> >::iterator c = mJobCounts.find(t);
|
||||||
|
return (c == mJobCounts.end()) ? 0 : (c->second.first + c->second.second);
|
||||||
|
}
|
||||||
|
|
||||||
int JobQueue::getJobCountGE(JobType t)
|
int JobQueue::getJobCountGE(JobType t)
|
||||||
{ // return the number of jobs at this priority level or greater
|
{ // return the number of jobs at this priority level or greater
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|||||||
@@ -103,8 +103,9 @@ public:
|
|||||||
|
|
||||||
void addJob(JobType type, const std::string& name, const boost::function<void(Job&)>& job);
|
void addJob(JobType type, const std::string& name, const boost::function<void(Job&)>& job);
|
||||||
|
|
||||||
int getJobCount(JobType t); // Jobs at this priority
|
int getJobCount(JobType t); // Jobs waiting at this priority
|
||||||
int getJobCountGE(JobType t); // All jobs at or greater than this priority
|
int getJobCountTotal(JobType t); // Jobs waiting plus running at this priority
|
||||||
|
int getJobCountGE(JobType t); // All waiting jobs at or greater than this priority
|
||||||
std::vector< std::pair<JobType, std::pair<int, int> > > getJobCounts(); // jobs waiting, threads doing
|
std::vector< std::pair<JobType, std::pair<int, int> > > getJobCounts(); // jobs waiting, threads doing
|
||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|||||||
@@ -512,7 +512,7 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus)
|
|||||||
if (!fromConsensus)
|
if (!fromConsensus)
|
||||||
dropCache();
|
dropCache();
|
||||||
|
|
||||||
if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) == 0)
|
if (theApp->getJobQueue().getJobCountTotal(jtPUBOLDLEDGER) == 0)
|
||||||
theApp->getLedgerMaster().resumeAcquiring();
|
theApp->getLedgerMaster().resumeAcquiring();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ void LedgerMaster::setFullLedger(Ledger::pointer ledger)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) > 2)
|
if (theApp->getJobQueue().getJobCountTotal(jtPUBOLDLEDGER) > 1)
|
||||||
{
|
{
|
||||||
cLog(lsDEBUG) << "Too many pending ledger saves";
|
cLog(lsDEBUG) << "Too many pending ledger saves";
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user