Don't be blind to validations during the idle time.

This commit is contained in:
JoelKatz
2012-08-01 15:00:39 -07:00
parent 68677270bf
commit a902134133
3 changed files with 34 additions and 2 deletions

View File

@@ -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)

View File

@@ -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();

View File

@@ -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)