mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Don't be blind to validations during the idle time.
This commit is contained in:
@@ -226,6 +226,38 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::pointer pre
|
||||
}
|
||||
}
|
||||
|
||||
void LedgerConsensus::checkLCL()
|
||||
{
|
||||
uint256 netLgr;
|
||||
int netLgrCount = 0;
|
||||
{
|
||||
boost::unordered_map<uint256, int> vals = theApp->getValidations().getCurrentValidations();
|
||||
for (boost::unordered_map<uint256, int>::iterator it = vals.begin(), end = vals.end(); it != end; ++it)
|
||||
if (it->second > netLgrCount)
|
||||
{
|
||||
netLgr = it->first;
|
||||
netLgrCount = it->second;
|
||||
}
|
||||
}
|
||||
if ((netLgrCount > 0) && (netLgr != mPrevLedgerHash))
|
||||
{ // LCL change
|
||||
Log(lsWARNING) << "View of consensus changed during consensus";
|
||||
mPrevLedgerHash = netLgr;
|
||||
mAcquiringLedger = theApp->getMasterLedgerAcquire().findCreate(mPrevLedgerHash);
|
||||
std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector();
|
||||
bool found = false;
|
||||
for (std::vector<Peer::pointer>::const_iterator it = peerList.begin(), end = peerList.end(); it != end; ++it)
|
||||
if ((*it)->hasLedger(mPrevLedgerHash))
|
||||
{
|
||||
found = true;
|
||||
mAcquiringLedger->peerHas(*it);
|
||||
}
|
||||
if (!found)
|
||||
for (std::vector<Peer::pointer>::const_iterator it = peerList.begin(), end = peerList.end(); it != end; ++it)
|
||||
mAcquiringLedger->peerHas(*it);
|
||||
}
|
||||
}
|
||||
|
||||
void LedgerConsensus::takeInitialPosition(Ledger& initialLedger)
|
||||
{
|
||||
SHAMap::pointer initialSet = initialLedger.peekTransactionMap()->snapShot(false);
|
||||
@@ -418,6 +450,7 @@ void LedgerConsensus::timerEntry()
|
||||
{
|
||||
if (!mHaveCorrectLCL)
|
||||
{
|
||||
checkLCL();
|
||||
Log(lsINFO) << "Checking for consensus ledger " << mPrevLedgerHash.GetHex();
|
||||
Ledger::pointer consensus = theApp->getMasterLedger().getLedgerByHash(mPrevLedgerHash);
|
||||
if (consensus)
|
||||
|
||||
@@ -149,6 +149,7 @@ public:
|
||||
SHAMap::pointer getTransactionTree(const uint256& hash, bool doAcquire);
|
||||
TransactionAcquire::pointer getAcquiring(const uint256& hash);
|
||||
void mapComplete(const uint256& hash, SHAMap::pointer map, bool acquired);
|
||||
void checkLCL();
|
||||
|
||||
void timerEntry();
|
||||
|
||||
|
||||
@@ -655,8 +655,6 @@ void NetworkOPs::endConsensus(bool correctLCL)
|
||||
(*it)->cycleStatus();
|
||||
}
|
||||
mConsensus = boost::shared_ptr<LedgerConsensus>();
|
||||
if (correctLCL && (mMode == omCONNECTED))
|
||||
setMode(omTRACKING);
|
||||
}
|
||||
|
||||
void NetworkOPs::setMode(OperatingMode om)
|
||||
|
||||
Reference in New Issue
Block a user