dht: don't send unnecessary findNode

This commit is contained in:
Adrien Béraud committed 2021-03-09 17:43:35 -05:00
1 parent 18a1a1c47f
commit 0b4caeda73
1 file changed
+7 -7
+7 -7
View File
@@ -382,7 +382,7 @@ Dht::searchSendGetValues(Sp<Search> sr, SearchNode* pn, bool update)
}
if (sr->callbacks.empty()) { /* 'find_node' request */
if (not n)
if (not n or n->isSynced(now))
return nullptr;
/* if (logger_)
@@ -491,9 +491,9 @@ void Dht::searchSendAnnounceValue(const Sp<Search>& sr) {
sr->id.toString().c_str(), sn->node->toString().c_str(), a.value->id);
sn->acked[a.value->id] = {
network_engine.sendRefreshValue(sn->node, sr->id, a.value->id, sn->token, onDone,
[this, ws, node=sn->node, v=a.value,
onDone,
onExpired,
[this, ws, node=sn->node, v=a.value,
onDone,
onExpired,
created = a.permanent ? time_point::max() : a.created,
next_refresh_time
](const net::Request& /*req*/, net::DhtProtocolException&& e){
@@ -591,7 +591,7 @@ Dht::searchSynchedNodeListen(const Sp<Search>& sr, SearchNode& n)
std::weak_ptr<Search> ws = sr;
for (const auto& l : sr->listeners) {
const auto& query = l.second.query;
auto r = n.listenStatus.find(query);
if (n.getListenTime(r, listenExp) > scheduler.time())
continue;
@@ -725,7 +725,7 @@ Dht::searchStep(Sp<Search> sr)
while (sr->currentlySolicitedNodeCount() < MAX_REQUESTED_SEARCH_NODES and searchSendGetValues(sr));
if (sr->getNumberOfConsecutiveBadNodes() >= std::min<size_t>(sr->nodes.size(), SEARCH_MAX_BAD_NODES))
{
if (logger_)
@@ -2528,7 +2528,7 @@ Dht::saveState(const std::string& path) const
state.nodes = exportNodes();
state.values = exportValues();
std::ofstream file(path);
msgpack::pack(file, state);
msgpack::pack(file, state);
}
void