On missing node in consensus, bow out (RIPD-567)

This commit is contained in:
JoelKatz
2014-09-18 11:54:16 -07:00
committed by Nik Bougalis
parent 526ecd6a81
commit 6aa325d3da

View File

@@ -316,7 +316,7 @@ public:
WriteLog (lsDEBUG, LedgerConsensus)
<< "Map " << hash << " is our current";
currentMap = currentMap->snapShot (false);
mapComplete (hash, currentMap, false);
mapCompleteInternal (hash, currentMap, false);
return currentMap;
}
}
@@ -334,7 +334,7 @@ public:
smtTRANSACTION,
app.getFullBelowCache(),
app.getTreeNodeCache());
mapComplete (hash, empty, false);
mapCompleteInternal (hash, empty, false);
return empty;
}
@@ -354,6 +354,21 @@ public:
@param acquired true if we have acquired the transaction set.
*/
void mapComplete (uint256 const& hash, SHAMap::ref map, bool acquired)
{
try
{
mapCompleteInternal (hash, map, acquired);
}
catch (SHAMapMissingNode const& mn)
{
leaveConsensus();
WriteLog (lsERROR, LedgerConsensus) <<
"Missind node processing complete map " << mn;
throw;
}
}
void mapCompleteInternal (uint256 const& hash, SHAMap::ref map, bool acquired)
{
CondLog (acquired, lsINFO, LedgerConsensus)
<< "We have acquired TXS " << hash;
@@ -620,6 +635,21 @@ public:
On timer call the correct handler for each state.
*/
void timerEntry ()
{
try
{
doTimer();
}
catch (SHAMapMissingNode const& mn)
{
leaveConsensus ();
WriteLog (lsERROR, LedgerConsensus) <<
"Missing node during consensus process " << mn;
throw;
}
}
void doTimer ()
{
if ((mState != lcsFINISHED) && (mState != lcsACCEPTED))
checkLCL ();
@@ -1358,6 +1388,23 @@ private:
}
}
/**
Revoke our outstanding proposal, if any, and
cease proposing at least until this round ends
*/
void leaveConsensus ()
{
if (mProposing)
{
if (mOurPosition && ! mOurPosition->isBowOut ())
{
mOurPosition->bowOut();
propose();
}
mProposing = false;
}
}
/** Make and send a proposal
*/
void propose ()
@@ -1650,7 +1697,7 @@ private:
uint256 txSet = initialSet->getHash ();
WriteLog (lsINFO, LedgerConsensus) << "initial position " << txSet;
mapComplete (txSet, initialSet, false);
mapCompleteInternal (txSet, initialSet, false);
if (mValidating)
{
@@ -1873,7 +1920,7 @@ private:
if (mProposing)
propose ();
mapComplete (newHash, ourPosition, false);
mapCompleteInternal (newHash, ourPosition, false);
}
}
}