mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Store index before publish (RIPD-1052, RIPD-1053)
This commit is contained in:
committed by
Nik Bougalis
parent
108906cb20
commit
3e5ec91977
@@ -89,7 +89,7 @@ public:
|
|||||||
|
|
||||||
// This is the last ledger we published to clients and can lag the validated
|
// This is the last ledger we published to clients and can lag the validated
|
||||||
// ledger
|
// ledger
|
||||||
virtual Ledger::ref getPublishedLedger () = 0;
|
virtual Ledger::pointer getPublishedLedger () = 0;
|
||||||
|
|
||||||
virtual bool isValidLedger(LedgerInfo const&) = 0;
|
virtual bool isValidLedger(LedgerInfo const&) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -423,6 +423,8 @@ public:
|
|||||||
// returns Ledgers we have all the nodes for
|
// returns Ledgers we have all the nodes for
|
||||||
bool getFullValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal) override
|
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();
|
maxVal = mPubLedgerSeq.load();
|
||||||
|
|
||||||
if (!maxVal)
|
if (!maxVal)
|
||||||
@@ -444,6 +446,8 @@ public:
|
|||||||
// Returns Ledgers we have all the nodes for and are indexed
|
// Returns Ledgers we have all the nodes for and are indexed
|
||||||
bool getValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal) override
|
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();
|
maxVal = mPubLedgerSeq.load();
|
||||||
|
|
||||||
if (!maxVal)
|
if (!maxVal)
|
||||||
@@ -1323,8 +1327,9 @@ public:
|
|||||||
|
|
||||||
// This is the last ledger we published to clients and can lag the validated
|
// This is the last ledger we published to clients and can lag the validated
|
||||||
// ledger.
|
// ledger.
|
||||||
Ledger::ref getPublishedLedger () override
|
Ledger::pointer getPublishedLedger () override
|
||||||
{
|
{
|
||||||
|
ScopedLockType lock(m_mutex);
|
||||||
return mPubLedger;
|
return mPubLedger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1703,20 +1708,31 @@ void LedgerMasterImp::doAdvance ()
|
|||||||
<< "tryAdvance acquired "
|
<< "tryAdvance acquired "
|
||||||
<< ledger->info().seq;
|
<< ledger->info().seq;
|
||||||
setFullLedger(ledger, false, false);
|
setFullLedger(ledger, false, false);
|
||||||
mHistLedger = ledger;
|
|
||||||
auto& parent = ledger->info().parentHash;
|
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)
|
getHashByIndex(seq - 1, app_) == parent)
|
||||||
{
|
{
|
||||||
// Previous ledger is in DB
|
{
|
||||||
ScopedLockType lock (m_mutex);
|
// Previous ledger is in DB
|
||||||
mFillInProgress = ledger->info().seq;
|
ScopedLockType lock(m_mutex);
|
||||||
|
mFillInProgress = ledger->info().seq;
|
||||||
|
}
|
||||||
|
|
||||||
app_.getJobQueue().addJob(
|
app_.getJobQueue().addJob(
|
||||||
jtADVANCE, "tryFill",
|
jtADVANCE, "tryFill",
|
||||||
[this, ledger] (Job& j) {
|
[this, ledger] (Job& j) {
|
||||||
tryFill(j, ledger);
|
tryFill(j, ledger);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
progress = true;
|
progress = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1782,13 +1798,17 @@ void LedgerMasterImp::doAdvance ()
|
|||||||
"tryAdvance publishing seq " << ledger->info().seq;
|
"tryAdvance publishing seq " << ledger->info().seq;
|
||||||
|
|
||||||
setFullLedger(ledger, true, true);
|
setFullLedger(ledger, true, true);
|
||||||
app_.getOPs().pubLedger(ledger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setPubLedger(ledger);
|
setPubLedger(ledger);
|
||||||
progress = true;
|
|
||||||
|
{
|
||||||
|
ScopedUnlockType sul(m_mutex);
|
||||||
|
app_.getOPs().pubLedger(ledger);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progress = true;
|
||||||
app_.getOPs().clearNeedNetworkLedger();
|
app_.getOPs().clearNeedNetworkLedger();
|
||||||
newPFWork ("pf:newLedger");
|
newPFWork ("pf:newLedger");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user