Store index before publish (RIPD-1052, RIPD-1053)

This commit is contained in:
Miguel Portilla
2015-11-18 08:44:42 -05:00
committed by Nik Bougalis
parent 108906cb20
commit 3e5ec91977
2 changed files with 29 additions and 9 deletions

View File

@@ -89,7 +89,7 @@ public:
// This is the last ledger we published to clients and can lag the validated
// ledger
virtual Ledger::ref getPublishedLedger () = 0;
virtual Ledger::pointer getPublishedLedger () = 0;
virtual bool isValidLedger(LedgerInfo const&) = 0;

View File

@@ -423,6 +423,8 @@ public:
// returns Ledgers we have all the nodes for
bool getFullValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal) override
{
// Validated ledger is likely not stored in the DB yet so we use the
// published ledger which is.
maxVal = mPubLedgerSeq.load();
if (!maxVal)
@@ -444,6 +446,8 @@ public:
// Returns Ledgers we have all the nodes for and are indexed
bool getValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal) override
{
// Validated ledger is likely not stored in the DB yet so we use the
// published ledger which is.
maxVal = mPubLedgerSeq.load();
if (!maxVal)
@@ -1323,8 +1327,9 @@ public:
// This is the last ledger we published to clients and can lag the validated
// ledger.
Ledger::ref getPublishedLedger () override
Ledger::pointer getPublishedLedger () override
{
ScopedLockType lock(m_mutex);
return mPubLedger;
}
@@ -1703,20 +1708,31 @@ void LedgerMasterImp::doAdvance ()
<< "tryAdvance acquired "
<< ledger->info().seq;
setFullLedger(ledger, false, false);
mHistLedger = ledger;
auto& parent = ledger->info().parentHash;
if (mFillInProgress == 0 &&
int fillInProgress;
{
ScopedLockType lock(m_mutex);
mHistLedger = ledger;
fillInProgress = mFillInProgress;
}
if (fillInProgress == 0 &&
getHashByIndex(seq - 1, app_) == parent)
{
// Previous ledger is in DB
ScopedLockType lock (m_mutex);
mFillInProgress = ledger->info().seq;
{
// Previous ledger is in DB
ScopedLockType lock(m_mutex);
mFillInProgress = ledger->info().seq;
}
app_.getJobQueue().addJob(
jtADVANCE, "tryFill",
[this, ledger] (Job& j) {
tryFill(j, ledger);
});
}
progress = true;
}
else
@@ -1782,13 +1798,17 @@ void LedgerMasterImp::doAdvance ()
"tryAdvance publishing seq " << ledger->info().seq;
setFullLedger(ledger, true, true);
app_.getOPs().pubLedger(ledger);
}
setPubLedger(ledger);
progress = true;
{
ScopedUnlockType sul(m_mutex);
app_.getOPs().pubLedger(ledger);
}
}
progress = true;
app_.getOPs().clearNeedNetworkLedger();
newPFWork ("pf:newLedger");
}