mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-05 08:48:03 +00:00
A few more fixes.
This commit is contained in:
@@ -561,11 +561,15 @@ void LedgerMaster::advanceThread()
|
||||
getFetchPack(nextLedger);
|
||||
if (!getApp().getInboundLedgers().isFailure(nextLedger->getParentHash()))
|
||||
{
|
||||
sl.unlock();
|
||||
InboundLedger::pointer acq =
|
||||
getApp().getInboundLedgers().findCreate(nextLedger->getParentHash(),
|
||||
nextLedger->getLedgerSeq() - 1);
|
||||
if (acq && acq->isComplete() && !acq->isFailed())
|
||||
ledger = acq->getLedger();
|
||||
sl.lock();
|
||||
if (mValidLedger->getLedgerSeq() != mPubLedger->getLedgerSeq())
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
if (ledger)
|
||||
@@ -632,23 +636,20 @@ std::list<Ledger::pointer> LedgerMaster::findNewLedgersToPublish()
|
||||
}
|
||||
else if (mValidLedger->getLedgerSeq () > mPubLedger->getLedgerSeq ())
|
||||
{
|
||||
int acq = 0;
|
||||
int acqCount = 0;
|
||||
for (uint32 seq = mPubLedger->getLedgerSeq () + 1; seq <= mValidLedger->getLedgerSeq (); ++seq)
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerMaster) << "Trying to publish ledger " << seq;
|
||||
|
||||
Ledger::pointer ledger;
|
||||
uint256 hash;
|
||||
uint256 hash = mValidLedger->getLedgerHash (seq);
|
||||
|
||||
if (seq == mValidLedger->getLedgerSeq ())
|
||||
{ // We need to publish the ledger we just fully validated
|
||||
ledger = mValidLedger;
|
||||
hash = ledger->getHash ();
|
||||
}
|
||||
else
|
||||
{
|
||||
hash = mValidLedger->getLedgerHash (seq);
|
||||
|
||||
if (hash.isZero ())
|
||||
{
|
||||
WriteLog (lsFATAL, LedgerMaster) << "Ledger: " << mValidLedger->getLedgerSeq () << " does not have hash for " <<
|
||||
@@ -659,7 +660,7 @@ std::list<Ledger::pointer> LedgerMaster::findNewLedgersToPublish()
|
||||
ledger = mLedgerHistory.getLedgerByHash (hash);
|
||||
}
|
||||
|
||||
if (!ledger && (++acq < 4))
|
||||
if (!ledger && (++acqCount < 4))
|
||||
{ // We can try to acquire the ledger we need
|
||||
InboundLedger::pointer acq = getApp().getInboundLedgers ().findCreate (hash, seq);
|
||||
|
||||
|
||||
@@ -29,15 +29,22 @@ InboundLedger::InboundLedger (uint256 const& hash, uint32 seq)
|
||||
tryLocal ();
|
||||
}
|
||||
|
||||
void InboundLedger::checkLocal ()
|
||||
// Returns true if progress is made
|
||||
bool InboundLedger::checkLocal ()
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
bool ret = false;
|
||||
|
||||
if (isDone ())
|
||||
return;
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
if (tryLocal ())
|
||||
done ();
|
||||
if (!isDone () && tryLocal())
|
||||
{
|
||||
done();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool InboundLedger::tryLocal ()
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
void addPeers ();
|
||||
void awaitData ();
|
||||
void noAwaitData ();
|
||||
void checkLocal ();
|
||||
bool checkLocal ();
|
||||
|
||||
typedef std::pair <protocol::TMGetObjectByHash::ObjectType, uint256> neededHash_t;
|
||||
|
||||
|
||||
@@ -257,12 +257,15 @@ void InboundLedgers::gotFetchPack (Job&)
|
||||
acquires.push_back (it.second);
|
||||
}
|
||||
|
||||
bool progress = false;
|
||||
BOOST_FOREACH (const InboundLedger::pointer & acquire, acquires)
|
||||
{
|
||||
acquire->checkLocal ();
|
||||
if (acquire->checkLocal ())
|
||||
progress = true;
|
||||
}
|
||||
|
||||
getApp().getLedgerMaster().tryAdvance();
|
||||
if (progress)
|
||||
getApp().getLedgerMaster().tryAdvance();
|
||||
}
|
||||
|
||||
void InboundLedgers::clearFailures ()
|
||||
|
||||
Reference in New Issue
Block a user