Skip to content

Commit

Permalink
feat: don't limit content search by # of responses
Browse files Browse the repository at this point in the history
Best I can tell, the limit on the number of maximum results is
copy-pasta from the recursive-find-nodes logic. (With confirmation from
Mike)

The query should continue until the content is found, rather than
stopping after too many peers return nodes on the way toward finding the
right content.
  • Loading branch information
carver committed Sep 13, 2024
1 parent 136613c commit e618e5c
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions portalnet/src/find/iterators/findcontent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,6 @@ where
return QueryState::Validating(peer);
}

// Count the number of peers that returned a result. If there is a
// request in progress to one of the `num_results` closest peers, the
// counter is set to `None` as the query can only finish once
// `num_results` closest peers have responded (or there are no more
// peers to contact, see `active_counter`).
let mut result_counter = Some(0);

// Check if the query is at capacity w.r.t. the allowed parallelism.
let at_capacity = self.at_capacity();

Expand Down Expand Up @@ -320,26 +313,10 @@ where
// The query is still waiting for a result from a peer and is
// at capacity w.r.t. the maximum number of peers being waited on.
return QueryState::WaitingAtCapacity;
} else {
// The query is still waiting for a result from a peer and the
// `result_counter` did not yet reach `num_results`. Therefore
// the query is not yet done, regardless of already successful
// queries to peers farther from the target.
result_counter = None;
}
}

QueryPeerState::Succeeded => {
if let Some(ref mut count) = result_counter {
*count += 1;
// If `num_results` successful results have been delivered for the
// closest peers, the query is done.
if *count >= self.config.num_results {
self.progress = QueryProgress::Finished;
return QueryState::Finished;
}
}
}
QueryPeerState::Succeeded => {}

QueryPeerState::Failed | QueryPeerState::Unresponsive => {
// Skip over unresponsive or failed peers.
Expand Down

0 comments on commit e618e5c

Please sign in to comment.