Speed up ledger acquiring.

This commit is contained in:
JoelKatz
2013-05-16 23:32:50 -07:00
parent fb7e01da41
commit 588ef7df86
5 changed files with 18 additions and 9 deletions

View File

@@ -107,14 +107,17 @@ LedgerAcquire::LedgerAcquire(const uint256& hash, uint32 seq) : PeerSet(hash, LE
tryLocal(); tryLocal();
} }
void LedgerAcquire::checkLocal() bool LedgerAcquire::checkLocal()
{ {
boost::recursive_mutex::scoped_lock sl(mLock); boost::recursive_mutex::scoped_lock sl(mLock);
if (isDone()) if (isDone())
return; return false;
if (!tryLocal())
return false;
if (tryLocal())
done(); done();
return true;
} }
bool LedgerAcquire::tryLocal() bool LedgerAcquire::tryLocal()
@@ -1064,13 +1067,20 @@ void LedgerAcquireMaster::gotFetchPack(Job&)
acquires.reserve(mLedgers.size()); acquires.reserve(mLedgers.size());
typedef std::pair<uint256, LedgerAcquire::pointer> u256_acq_pair; typedef std::pair<uint256, LedgerAcquire::pointer> u256_acq_pair;
BOOST_FOREACH(const u256_acq_pair& it, mLedgers) BOOST_FOREACH(const u256_acq_pair& it, mLedgers)
{
acquires.push_back(it.second); acquires.push_back(it.second);
} }
}
int completed = 0;
BOOST_FOREACH(const LedgerAcquire::pointer& acquire, acquires) BOOST_FOREACH(const LedgerAcquire::pointer& acquire, acquires)
{ {
acquire->checkLocal(); if (acquire->checkLocal())
++completed;
} }
if (completed > 0)
theApp->getLedgerMaster().resumeAcquiring();
} }
// vim:ts=4 // vim:ts=4

View File

@@ -130,7 +130,7 @@ public:
void addPeers(); void addPeers();
void awaitData(); void awaitData();
void noAwaitData(); void noAwaitData();
void checkLocal(); bool checkLocal();
typedef std::pair<ripple::TMGetObjectByHash::ObjectType, uint256> neededHash_t; typedef std::pair<ripple::TMGetObjectByHash::ObjectType, uint256> neededHash_t;
std::vector<neededHash_t> getNeededHashes(); std::vector<neededHash_t> getNeededHashes();

View File

@@ -2121,7 +2121,7 @@ void NetworkOPs::gotFetchPack(bool progress, uint32 seq)
mLastFetchPack = 0; mLastFetchPack = 0;
mFetchSeq = seq; // earliest pack we have data on mFetchSeq = seq; // earliest pack we have data on
theApp->getJobQueue().addJob(jtLEDGER_DATA, "gotFetchPack", theApp->getJobQueue().addJob(jtLEDGER_DATA, "gotFetchPack",
boost::bind(&LedgerAcquireMaster::gotFetchPack, &theApp->getMasterLedgerAcquire(), _1)); BIND_TYPE(&LedgerAcquireMaster::gotFetchPack, &theApp->getMasterLedgerAcquire(), P_1));
} }
void NetworkOPs::missingNodeInLedger(uint32 seq) void NetworkOPs::missingNodeInLedger(uint32 seq)

View File

@@ -260,7 +260,6 @@ SHAMapTreeNode* SHAMap::getNodePointer(const SHAMapNode& id, const uint256& hash
} }
} }
void SHAMap::returnNode(SHAMapTreeNode::pointer& node, bool modify) void SHAMap::returnNode(SHAMapTreeNode::pointer& node, bool modify)
{ // make sure the node is suitable for the intended operation (copy on write) { // make sure the node is suitable for the intended operation (copy on write)
assert(node->isValid()); assert(node->isValid());

View File

@@ -126,7 +126,7 @@ std::vector<uint256> SHAMap::getNeededHashes(int max, SHAMapSyncFilter* filter)
try try
{ {
d = getNodePointer(childID, childHash, filter); d = getNodePointer(childID, childHash, filter);
if (d->isInner() && !d->isFullBelow()) if (d->isInner())
{ {
have_all = false; have_all = false;
stack.push(d); stack.push(d);