Skip to content

Commit

Permalink
chore: increase quotes fetch sample to 10
Browse files Browse the repository at this point in the history
  • Loading branch information
mickvandijke committed Jan 24, 2025
1 parent eb76bcf commit 6fa416f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ant-networking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ impl Network {
&self,
key: &NetworkAddress,
) -> Result<Vec<PeerId>> {
self.get_all_close_peers_in_range_or_close_group(key, true)
self.get_all_close_peers_in_range_or_close_group(key, true, Some(CLOSE_GROUP_SIZE * 2))
.await
}

/// Returns the closest peers to the given `NetworkAddress`, sorted by their distance to the key.
///
/// Includes our node's `PeerId` while calculating the closest peers.
pub async fn node_get_closest_peers(&self, key: &NetworkAddress) -> Result<Vec<PeerId>> {
self.get_all_close_peers_in_range_or_close_group(key, false)
self.get_all_close_peers_in_range_or_close_group(key, false, None)
.await
}

Expand Down Expand Up @@ -409,7 +409,7 @@ impl Network {

// consider data to be already paid for if 1/2 of the close nodes already have it
let mut peer_already_have_it = 0;
let enough_peers_already_have_it = close_nodes.len() / 2;
let enough_peers_already_have_it = CLOSE_GROUP_SIZE / 2 + 1;

// loop over responses
let mut all_quotes = vec![];
Expand Down Expand Up @@ -1075,6 +1075,7 @@ impl Network {
&self,
key: &NetworkAddress,
client: bool,
expanded_close_group_size: Option<usize>,
) -> Result<Vec<PeerId>> {
let pretty_key = PrettyPrintKBucketKey(key.as_kbucket_key());
debug!("Getting the all closest peers in range of {pretty_key:?}");
Expand Down Expand Up @@ -1115,7 +1116,8 @@ impl Network {
);
}

let expanded_close_group = CLOSE_GROUP_SIZE + CLOSE_GROUP_SIZE / 2;
let expanded_close_group =
expanded_close_group_size.unwrap_or_else(|| CLOSE_GROUP_SIZE + CLOSE_GROUP_SIZE / 2);
let closest_peers = sort_peers_by_address(&closest_peers, key, expanded_close_group)?;
Ok(closest_peers.into_iter().cloned().collect())
}
Expand Down

0 comments on commit 6fa416f

Please sign in to comment.