mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Handler to run all pathfinding requests.
This commit is contained in:
@@ -248,4 +248,47 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PFRequest::updateAll(const boost::shared_ptr<Ledger>& ledger)
|
||||
{
|
||||
assert(ledger->isImmutable());
|
||||
|
||||
std::set<wptr> requests;
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(sLock);
|
||||
requests = sRequests;
|
||||
}
|
||||
|
||||
if (requests.empty())
|
||||
return;
|
||||
|
||||
RLCache::pointer cache = boost::make_shared<RLCache>(ledger);
|
||||
|
||||
BOOST_FOREACH(wref wRequest, requests)
|
||||
{
|
||||
bool remove = true;
|
||||
PFRequest::pointer pRequest = wRequest.lock();
|
||||
if (pRequest)
|
||||
{
|
||||
InfoSub::pointer ipSub = pRequest->wpSubscriber.lock();
|
||||
if (ipSub)
|
||||
{
|
||||
Json::Value update;
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(pRequest->mLock);
|
||||
pRequest->doUpdate(cache, true);
|
||||
update = pRequest->jvStatus;
|
||||
}
|
||||
update["type"] = "path_find";
|
||||
ipSub->send(update, false);
|
||||
remove = false;
|
||||
}
|
||||
}
|
||||
if (remove)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(sLock);
|
||||
sRequests.erase(wRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
typedef boost::weak_ptr<PFRequest> wptr;
|
||||
typedef boost::shared_ptr<PFRequest> pointer;
|
||||
typedef const pointer& ref;
|
||||
typedef const wptr& wref;
|
||||
typedef std::pair<uint160, uint160> currIssuer_t;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user