aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-05 20:08:02 +0100
committertv <tv@krebsco.de>2026-11-05 20:08:02 +0100
commit43bc3f13066ba0ee436c55b744978059e8cc8bda (patch)
tree43d41ebd78e5313c6feed2c4d9d86e4cc8676520
parent9aad4bee0fbcac76e96b3ff4e6c57a28b162b861 (diff)
offerer asked first
-rw-r--r--src/swarm/blob.rs6
-rw-r--r--src/swarm/sync.rs1
2 files changed, 5 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() {
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs
index 5100b98..62bb27e 100644
--- a/src/swarm/sync.rs
+++ b/src/swarm/sync.rs
@@ -752,6 +752,7 @@ async fn download_and_apply_delta(
epoch: transport::Epoch,
spec: transport::DeltaSpec,
) -> Result<bool> {
+ // The offerer first: it holds what it offers (`blob::fetch` asks it first).
let mut peers = vec![peer.to_owned()];
peers.extend(
state