mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 13:35:54 +00:00
More fetch pack work.
This commit is contained in:
@@ -118,7 +118,7 @@ bool LedgerAcquire::tryLocal()
|
|||||||
std::vector<unsigned char> data;
|
std::vector<unsigned char> data;
|
||||||
if (!theApp->getOPs().getFetchPack(mHash, data))
|
if (!theApp->getOPs().getFetchPack(mHash, data))
|
||||||
return false;
|
return false;
|
||||||
cLog(lsINFO) << "Ledger base found in fetch pack";
|
cLog(lsTRACE) << "Ledger base found in fetch pack";
|
||||||
mLedger = boost::make_shared<Ledger>(data, true);
|
mLedger = boost::make_shared<Ledger>(data, true);
|
||||||
theApp->getHashedObjectStore().store(hotLEDGER, mLedger->getLedgerSeq(), data, mHash);
|
theApp->getHashedObjectStore().store(hotLEDGER, mLedger->getLedgerSeq(), data, mHash);
|
||||||
}
|
}
|
||||||
@@ -792,7 +792,13 @@ LedgerAcquire::pointer LedgerAcquireMaster::findCreate(const uint256& hash)
|
|||||||
ptr->setTimer(); // Cannot call in constructor
|
ptr->setTimer(); // Cannot call in constructor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
Ledger::pointer ledger = ptr->getLedger();
|
||||||
|
ledger->setClosed();
|
||||||
|
ledger->setImmutable();
|
||||||
|
theApp->getLedgerMaster().storeLedger(ledger);
|
||||||
cLog(lsDEBUG) << "Acquiring ledger we already have: " << hash;
|
cLog(lsDEBUG) << "Acquiring ledger we already have: " << hash;
|
||||||
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,38 @@ bool LedgerMaster::acquireMissingLedger(Ledger::ref origLedger, const uint256& l
|
|||||||
theApp->getIOService().post(boost::bind(&LedgerMaster::missingAcquireComplete, this, mMissingLedger));
|
theApp->getIOService().post(boost::bind(&LedgerMaster::missingAcquireComplete, this, mMissingLedger));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fetchMax = theConfig.getSize(siLedgerFetch);
|
||||||
|
int timeoutCount;
|
||||||
|
int fetchCount = theApp->getMasterLedgerAcquire().getFetchCount(timeoutCount);
|
||||||
|
|
||||||
|
if ((fetchCount < fetchMax) && theApp->getOPs().isFull())
|
||||||
|
{
|
||||||
|
if (timeoutCount > 2)
|
||||||
|
{
|
||||||
|
cLog(lsDEBUG) << "Not acquiring due to timeouts";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
typedef std::pair<uint32, uint256> u_pair;
|
||||||
|
std::vector<u_pair> vec = origLedger->getLedgerHashes();
|
||||||
|
BOOST_FOREACH(const u_pair& it, vec)
|
||||||
|
{
|
||||||
|
if ((fetchCount < fetchMax) && (it.first < ledgerSeq) &&
|
||||||
|
!mCompleteLedgers.hasValue(it.first) && !theApp->getMasterLedgerAcquire().find(it.second))
|
||||||
|
{
|
||||||
|
LedgerAcquire::pointer acq = theApp->getMasterLedgerAcquire().findCreate(it.second);
|
||||||
|
if (acq && acq->isComplete())
|
||||||
|
{
|
||||||
|
acq->getLedger()->setAccepted();
|
||||||
|
setFullLedger(acq->getLedger());
|
||||||
|
mLedgerHistory.addAcceptedLedger(acq->getLedger(), false);
|
||||||
|
}
|
||||||
|
else ++fetchCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (theApp->getOPs().shouldFetchPack())
|
if (theApp->getOPs().shouldFetchPack())
|
||||||
{ // refill our fetch pack
|
{ // refill our fetch pack
|
||||||
Ledger::pointer nextLedger = mLedgerHistory.getLedgerBySeq(ledgerSeq + 1);
|
Ledger::pointer nextLedger = mLedgerHistory.getLedgerBySeq(ledgerSeq + 1);
|
||||||
@@ -286,32 +318,6 @@ bool LedgerMaster::acquireMissingLedger(Ledger::ref origLedger, const uint256& l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int fetchMax = theConfig.getSize(siLedgerFetch);
|
|
||||||
int timeoutCount;
|
|
||||||
int fetchCount = theApp->getMasterLedgerAcquire().getFetchCount(timeoutCount);
|
|
||||||
|
|
||||||
if ((fetchCount < fetchMax) && theApp->getOPs().isFull())
|
|
||||||
{
|
|
||||||
if (timeoutCount > 2)
|
|
||||||
{
|
|
||||||
cLog(lsDEBUG) << "Not acquiring due to timeouts";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
typedef std::pair<uint32, uint256> u_pair;
|
|
||||||
std::vector<u_pair> vec = origLedger->getLedgerHashes();
|
|
||||||
BOOST_FOREACH(const u_pair& it, vec)
|
|
||||||
{
|
|
||||||
if ((fetchCount < fetchMax) && (it.first < ledgerSeq) &&
|
|
||||||
!mCompleteLedgers.hasValue(it.first) && !theApp->getMasterLedgerAcquire().find(it.second))
|
|
||||||
{
|
|
||||||
++fetchCount;
|
|
||||||
theApp->getMasterLedgerAcquire().findCreate(it.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2088,7 +2088,6 @@ bool NetworkOPs::getFetchPack(const uint256& hash, std::vector<unsigned char>& d
|
|||||||
cLog(lsWARNING) << "Bad entry in fetch pack";
|
cLog(lsWARNING) << "Bad entry in fetch pack";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cLog(lsINFO) << hash << " found in fetch pack";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user