mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Get rid of "dead" ledgers. We don't need them any more and they make trouble.
Fix close time synch to be more accurate.
This commit is contained in:
@@ -257,7 +257,7 @@ void LedgerConsensus::checkLCL()
|
||||
typedef std::pair<const uint256, int> u256_int_pair;
|
||||
BOOST_FOREACH(u256_int_pair& it, vals)
|
||||
{
|
||||
if ((it.second > netLgrCount) && !theApp->getValidations().isDeadLedger(it.first))
|
||||
if (it.second > netLgrCount)
|
||||
{
|
||||
netLgr = it.first;
|
||||
netLgrCount = it.second;
|
||||
|
||||
@@ -56,8 +56,13 @@ uint32 NetworkOPs::getValidationTimeNC()
|
||||
}
|
||||
|
||||
void NetworkOPs::closeTimeOffset(int offset)
|
||||
{
|
||||
mCloseTimeOffset += offset / 4;
|
||||
{ // take large offsets, ignore small offsets, push towards our wall time
|
||||
if (offset > 1)
|
||||
mCloseTimeOffset += (offset + 3) / 4;
|
||||
else if (offset < -1)
|
||||
mCloseTimeOffset += (offset - 3) / 4;
|
||||
else
|
||||
mCloseTimeOffset = (mCloseTimeOffset * 3) / 4;
|
||||
if (mCloseTimeOffset)
|
||||
Log(lsINFO) << "Close time offset now " << mCloseTimeOffset;
|
||||
}
|
||||
@@ -487,10 +492,9 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
|
||||
for (boost::unordered_map<uint256, ValidationCount>::iterator it = ledgers.begin(), end = ledgers.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
bool isDead = theApp->getValidations().isDeadLedger(it->first);
|
||||
Log(lsTRACE) << "L: " << it->first << ((isDead) ? " dead" : " live") <<
|
||||
" t=" << it->second.trustedValidations << ", n=" << it->second.nodesUsing;
|
||||
if ((it->second > bestVC) && !isDead)
|
||||
Log(lsTRACE) << "L: " << it->first << " t=" << it->second.trustedValidations <<
|
||||
", n=" << it->second.nodesUsing;
|
||||
if (it->second > bestVC)
|
||||
{
|
||||
bestVC = it->second;
|
||||
closedLedger = it->first;
|
||||
@@ -718,8 +722,6 @@ void NetworkOPs::mapComplete(const uint256& hash, const SHAMap::pointer& map)
|
||||
void NetworkOPs::endConsensus(bool correctLCL)
|
||||
{
|
||||
uint256 deadLedger = theApp->getMasterLedger().getClosedLedger()->getParentHash();
|
||||
Log(lsTRACE) << "Ledger " << deadLedger << " is now dead";
|
||||
theApp->getValidations().addDeadLedger(deadLedger);
|
||||
std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector();
|
||||
BOOST_FOREACH(Peer::ref it, peerList)
|
||||
if (it && (it->getClosedLedgerHash() == deadLedger))
|
||||
|
||||
@@ -164,28 +164,6 @@ boost::unordered_map<uint256, int> ValidationCollection::getCurrentValidations(u
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ValidationCollection::isDeadLedger(const uint256& ledger)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mValidationLock);
|
||||
BOOST_FOREACH(const uint256& it, mDeadLedgers)
|
||||
if (it == ledger)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ValidationCollection::addDeadLedger(const uint256& ledger)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mValidationLock);
|
||||
|
||||
BOOST_FOREACH(const uint256& it, mDeadLedgers)
|
||||
if (it == ledger)
|
||||
return;
|
||||
|
||||
mDeadLedgers.push_back(ledger);
|
||||
if (mDeadLedgers.size() >= 32)
|
||||
mDeadLedgers.pop_front();
|
||||
}
|
||||
|
||||
void ValidationCollection::flush()
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mValidationLock);
|
||||
|
||||
@@ -20,7 +20,6 @@ protected:
|
||||
boost::unordered_map<uint256, ValidationSet> mValidations;
|
||||
boost::unordered_map<uint160, SerializedValidation::pointer> mCurrentValidations;
|
||||
std::vector<SerializedValidation::pointer> mStaleValidations;
|
||||
std::list<uint256> mDeadLedgers;
|
||||
|
||||
bool mWriting;
|
||||
|
||||
@@ -39,10 +38,6 @@ public:
|
||||
|
||||
boost::unordered_map<uint256, int> getCurrentValidations(uint256 currentLedger = uint256());
|
||||
|
||||
void addDeadLedger(const uint256&);
|
||||
bool isDeadLedger(const uint256&);
|
||||
std::list<uint256> getDeadLedgers() { return mDeadLedgers; }
|
||||
|
||||
void flush();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user