mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 05:25:55 +00:00
Fix a bug where a node doesn't get a chance to finish acquiring a TX set
before all nodes forget it because they're done with it, leaving a node behind the consensus.
This commit is contained in:
@@ -827,7 +827,6 @@ SHAMap::pointer LedgerConsensus::getTransactionTree(const uint256& hash, bool do
|
|||||||
SHAMap::pointer currentMap = theApp->getLedgerMaster().getCurrentLedger()->peekTransactionMap();
|
SHAMap::pointer currentMap = theApp->getLedgerMaster().getCurrentLedger()->peekTransactionMap();
|
||||||
if (currentMap->getHash() == hash)
|
if (currentMap->getHash() == hash)
|
||||||
{
|
{
|
||||||
cLog(lsINFO) << "node proposes our open transaction set";
|
|
||||||
currentMap = currentMap->snapShot(false);
|
currentMap = currentMap->snapShot(false);
|
||||||
mapComplete(hash, currentMap, false);
|
mapComplete(hash, currentMap, false);
|
||||||
return currentMap;
|
return currentMap;
|
||||||
@@ -1193,6 +1192,9 @@ uint32 LedgerConsensus::roundCloseTime(uint32 closeTime)
|
|||||||
|
|
||||||
void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
|
void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
|
||||||
{
|
{
|
||||||
|
if (set->getHash().isNonZero())
|
||||||
|
theApp->getOPs().takePosition(mPreviousLedger->getLedgerSeq(), set);
|
||||||
|
|
||||||
boost::recursive_mutex::scoped_lock masterLock(theApp->getMasterLock());
|
boost::recursive_mutex::scoped_lock masterLock(theApp->getMasterLock());
|
||||||
assert(set->getHash() == mOurPosition->getCurrentHash());
|
assert(set->getHash() == mOurPosition->getCurrentHash());
|
||||||
|
|
||||||
|
|||||||
@@ -906,11 +906,32 @@ void NetworkOPs::processTrustedProposal(LedgerProposal::pointer proposal,
|
|||||||
|
|
||||||
SHAMap::pointer NetworkOPs::getTXMap(const uint256& hash)
|
SHAMap::pointer NetworkOPs::getTXMap(const uint256& hash)
|
||||||
{
|
{
|
||||||
|
std::map<uint256, std::pair<int, SHAMap::pointer> >::iterator it = mRecentPositions.find(hash);
|
||||||
|
if (it != mRecentPositions.end())
|
||||||
|
return it->second.second;
|
||||||
if (!haveConsensusObject())
|
if (!haveConsensusObject())
|
||||||
return SHAMap::pointer();
|
return SHAMap::pointer();
|
||||||
return mConsensus->getTransactionTree(hash, false);
|
return mConsensus->getTransactionTree(hash, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkOPs::takePosition(int seq, SHAMap::ref position)
|
||||||
|
{
|
||||||
|
mRecentPositions[position->getHash()] = std::make_pair(seq, position);
|
||||||
|
if (mRecentPositions.size() > 4)
|
||||||
|
{
|
||||||
|
std::map<uint256, std::pair<int, SHAMap::pointer> >::iterator it = mRecentPositions.begin();
|
||||||
|
while (it != mRecentPositions.end())
|
||||||
|
{
|
||||||
|
if (it->second.first < (seq - 2))
|
||||||
|
{
|
||||||
|
mRecentPositions.erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SMAddNode NetworkOPs::gotTXData(const boost::shared_ptr<Peer>& peer, const uint256& hash,
|
SMAddNode NetworkOPs::gotTXData(const boost::shared_ptr<Peer>& peer, const uint256& hash,
|
||||||
const std::list<SHAMapNode>& nodeIDs, const std::list< std::vector<unsigned char> >& nodeData)
|
const std::list<SHAMapNode>& nodeIDs, const std::list< std::vector<unsigned char> >& nodeData)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ protected:
|
|||||||
uint32 mLastValidationTime;
|
uint32 mLastValidationTime;
|
||||||
SerializedValidation::pointer mLastValidation;
|
SerializedValidation::pointer mLastValidation;
|
||||||
|
|
||||||
|
// Recent positions taken
|
||||||
|
std::map<uint256, std::pair<int, SHAMap::pointer> > mRecentPositions;
|
||||||
|
|
||||||
// XXX Split into more locks.
|
// XXX Split into more locks.
|
||||||
boost::recursive_mutex mMonitorLock;
|
boost::recursive_mutex mMonitorLock;
|
||||||
@@ -209,6 +211,7 @@ public:
|
|||||||
SMAddNode gotTXData(const boost::shared_ptr<Peer>& peer, const uint256& hash,
|
SMAddNode gotTXData(const boost::shared_ptr<Peer>& peer, const uint256& hash,
|
||||||
const std::list<SHAMapNode>& nodeIDs, const std::list< std::vector<unsigned char> >& nodeData);
|
const std::list<SHAMapNode>& nodeIDs, const std::list< std::vector<unsigned char> >& nodeData);
|
||||||
bool recvValidation(const SerializedValidation::pointer& val);
|
bool recvValidation(const SerializedValidation::pointer& val);
|
||||||
|
void takePosition(int seq, SHAMap::ref position);
|
||||||
SHAMap::pointer getTXMap(const uint256& hash);
|
SHAMap::pointer getTXMap(const uint256& hash);
|
||||||
bool hasTXSet(const boost::shared_ptr<Peer>& peer, const uint256& set, ripple::TxSetStatus status);
|
bool hasTXSet(const boost::shared_ptr<Peer>& peer, const uint256& set, ripple::TxSetStatus status);
|
||||||
void mapComplete(const uint256& hash, SHAMap::ref map);
|
void mapComplete(const uint256& hash, SHAMap::ref map);
|
||||||
|
|||||||
Reference in New Issue
Block a user