mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Correctly sequence to acquiring a new LCL if it changes. Don't keep acquiring the old one.
This commit is contained in:
@@ -84,7 +84,7 @@ void PeerSet::TimerEntry(boost::weak_ptr<PeerSet> wptr, const boost::system::err
|
||||
}
|
||||
|
||||
LedgerAcquire::LedgerAcquire(const uint256& hash) : PeerSet(hash, LEDGER_ACQUIRE_TIMEOUT),
|
||||
mHaveBase(false), mHaveState(false), mHaveTransactions(false)
|
||||
mHaveBase(false), mHaveState(false), mHaveTransactions(false), mAborted(false)
|
||||
{
|
||||
#ifdef LA_DEBUG
|
||||
Log(lsTRACE) << "Acquiring ledger " << mHash.GetHex();
|
||||
@@ -122,6 +122,8 @@ void LedgerAcquire::addOnComplete(boost::function<void (LedgerAcquire::pointer)>
|
||||
|
||||
void LedgerAcquire::trigger(Peer::pointer peer)
|
||||
{
|
||||
if (mAborted)
|
||||
return;
|
||||
#ifdef LA_DEBUG
|
||||
if(peer) Log(lsTRACE) << "Trigger acquiring ledger " << mHash.GetHex() << " from " << peer->getIP();
|
||||
else Log(lsTRACE) << "Trigger acquiring ledger " << mHash.GetHex();
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
|
||||
protected:
|
||||
Ledger::pointer mLedger;
|
||||
bool mHaveBase, mHaveState, mHaveTransactions;
|
||||
bool mHaveBase, mHaveState, mHaveTransactions, mAborted;
|
||||
|
||||
std::vector< boost::function<void (LedgerAcquire::pointer)> > mOnComplete;
|
||||
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
bool isAcctStComplete() const { return mHaveState; }
|
||||
bool isTransComplete() const { return mHaveTransactions; }
|
||||
Ledger::pointer getLedger() { return mLedger; }
|
||||
void abort() { mAborted = true; }
|
||||
|
||||
void addOnComplete(boost::function<void (LedgerAcquire::pointer)>);
|
||||
|
||||
|
||||
@@ -401,7 +401,15 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
|
||||
networkClosed = closedLedger;
|
||||
|
||||
if (!switchLedgers)
|
||||
{
|
||||
if (mAcquiringLedger)
|
||||
{
|
||||
mAcquiringLedger->abort();
|
||||
theApp->getMasterLedgerAcquire().dropLedger(mAcquiringLedger->getHash());
|
||||
mAcquiringLedger = LedgerAcquire::pointer();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Log(lsWARNING) << "We are not running on the consensus ledger";
|
||||
Log(lsINFO) << "Our LCL " << ourClosed->getHash().GetHex();
|
||||
@@ -412,14 +420,14 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
|
||||
if (!consensus)
|
||||
{
|
||||
Log(lsINFO) << "Acquiring consensus ledger";
|
||||
LedgerAcquire::pointer acq = theApp->getMasterLedgerAcquire().findCreate(closedLedger);
|
||||
if (!acq || acq->isFailed())
|
||||
LedgerAcquire::pointer mAcquiringLedger = theApp->getMasterLedgerAcquire().findCreate(closedLedger);
|
||||
if (!mAcquiringLedger || mAcquiringLedger->isFailed())
|
||||
{
|
||||
theApp->getMasterLedgerAcquire().dropLedger(closedLedger);
|
||||
Log(lsERROR) << "Network ledger cannot be acquired";
|
||||
return true;
|
||||
}
|
||||
if (!acq->isComplete())
|
||||
if (!mAcquiringLedger->isComplete())
|
||||
{ // add more peers
|
||||
int count = 0;
|
||||
std::vector<Peer::pointer> peers=theApp->getConnectionPool().getPeerVector();
|
||||
@@ -429,7 +437,7 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
|
||||
if ((*it)->getClosedLedgerHash() == closedLedger)
|
||||
{
|
||||
++count;
|
||||
acq->peerHas(*it);
|
||||
mAcquiringLedger->peerHas(*it);
|
||||
}
|
||||
}
|
||||
if (!count)
|
||||
@@ -438,12 +446,12 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
|
||||
it != end; ++it)
|
||||
{
|
||||
if ((*it)->isConnected())
|
||||
acq->peerHas(*it);
|
||||
mAcquiringLedger->peerHas(*it);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
consensus = acq->getLedger();
|
||||
consensus = mAcquiringLedger->getLedger();
|
||||
}
|
||||
|
||||
// FIXME: If this rewinds the ledger sequence, or has the same sequence, we should update the status on
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "NicknameState.h"
|
||||
#include "RippleState.h"
|
||||
#include "SerializedValidation.h"
|
||||
#include "LedgerAcquire.h"
|
||||
|
||||
#include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
|
||||
#include <boost/interprocess/sync/sharable_lock.hpp>
|
||||
@@ -51,6 +52,7 @@ protected:
|
||||
boost::shared_ptr<LedgerConsensus> mConsensus;
|
||||
|
||||
LedgerMaster* mLedgerMaster;
|
||||
LedgerAcquire::pointer mAcquiringLedger;
|
||||
|
||||
void setMode(OperatingMode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user