aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/blob.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm/blob.rs')
-rw-r--r--src/swarm/blob.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/swarm/blob.rs b/src/swarm/blob.rs
index f3494af..588868f 100644
--- a/src/swarm/blob.rs
+++ b/src/swarm/blob.rs
@@ -474,7 +474,9 @@ pub(crate) async fn fetch(
}
let _registration = Registration { state, id };
- // Closest first; peers without a round-trip time last.
+ // Closest first; peers without a round-trip time last. For a delta, the first is
+ // the one that offered it, which holds it: asked first however far.
+ let offerer = delta.and_then(|_| peers.first().cloned());
let now = Instant::now();
let mut peers: Vec<(String, Option<Duration>)> = {
let rtt = state.lock_rtt();
@@ -486,7 +488,7 @@ pub(crate) async fn fetch(
})
.collect()
};
- peers.sort_by_key(|(_, rtt)| rtt.unwrap_or(Duration::MAX));
+ peers.sort_by_key(|(peer, rtt)| (offerer.as_ref() != Some(peer), rtt.unwrap_or(Duration::MAX)));
let rtts: HashMap<String, Option<Duration>> = peers.iter().cloned().collect();
let mut candidates: VecDeque<String> = peers.into_iter().map(|(peer, _)| peer).collect();
if candidates.is_empty() {