[verified] fix(file): pace chunks to fit rendezvous rate limit
All checks were successful
ci / test (pull_request) Successful in 2m42s

Sender-side only. First chunk attempt is immediate; later attempts
(retries and later chunks) wait 3s. Three attempts per chunk, then
fail closed. Token bucket 30/60s burst 10 is unchanged.

A 1 MiB file is 17 one-shot sessions; pacing floor is 16*3s = 48s
plus handshake time. Latency trade, not a security fix.
This commit is contained in:
Sirius DevOps 2026-09-11 23:49:29 -04:00
commit 4bbc2de9ab
No known key found for this signature in database
5 changed files with 122 additions and 4 deletions

View file

@ -486,12 +486,13 @@ impl Node {
}
/// One-shot file to a friend. Fail closed; no outbox, no resume.
/// Chunks are paced (`file::CHUNK_PACE`) with bounded per-chunk retry so
/// a 1 MiB transfer fits the receiver's rendezvous token bucket.
pub async fn send_file(&self, friend_pk: &[u8], path: &Path) -> Result<String, String> {
let (name, bytes) = file::read_limited(path).map_err(|e| e.to_string())?;
let chunks = file::chunks(&name, &bytes).map_err(|e| e.to_string())?;
for chunk in &chunks {
self.send_once(friend_pk, &file::encode(chunk)).await?;
}
let frames: Vec<Vec<u8>> = chunks.iter().map(file::encode).collect();
file::send_chunks(frames.len(), |i| self.send_once(friend_pk, &frames[i])).await?;
self.store
.lock()
.map_err(|e| e.to_string())?