summaryrefslogtreecommitdiffstats
path: root/src/remake
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-26 20:45:38 +0100
committertv <tv@krebsco.de>2026-10-26 20:45:38 +0100
commit88417aa0660b0766f3c75bf5846361528537e0b9 (patch)
treec2fddb5f536b3dcc1c79fd7369462c240ae9bf48 /src/remake
parentc598d9c25bc2d1f07044040aae6e1264ef7ada36 (diff)
introduce bounded blob downloads
Diffstat (limited to 'src/remake')
-rw-r--r--src/remake/content.rs2
-rw-r--r--src/remake/mod.rs11
2 files changed, 8 insertions, 5 deletions
diff --git a/src/remake/content.rs b/src/remake/content.rs
index f3e549e..d036b87 100644
--- a/src/remake/content.rs
+++ b/src/remake/content.rs
@@ -66,7 +66,7 @@ pub(super) async fn ensure<H: Host>(
}
async fn fetch<H: Host>(host: &H, hash: [u8; 32], reference: &ContentRef) -> Option<Arc<Vec<u8>>> {
- match host.fetch_content(hash).await {
+ match host.fetch_content(hash, reference.size).await {
Ok(bytes) if bytes.len() as u64 == reference.size => {
info!(content = %reference.blake3, bytes = bytes.len(), "Downloaded remake content");
let bytes = Arc::new(bytes);
diff --git a/src/remake/mod.rs b/src/remake/mod.rs
index 38c2b9c..ad027a7 100644
--- a/src/remake/mod.rs
+++ b/src/remake/mod.rs
@@ -87,10 +87,13 @@ pub(crate) trait Host: Clone + Send + Sync + 'static {
hash: automerge::ChangeHash,
) -> impl Future<Output = anyhow::Result<automerge::Change>> + Send;
- /// Downloads content by its BLAKE3 hash from peers on the local epoch, checked
- /// against it.
- fn fetch_content(&self, hash: [u8; 32])
- -> impl Future<Output = anyhow::Result<Vec<u8>>> + Send;
+ /// Downloads content of `size` bytes by its BLAKE3 hash from peers on the local
+ /// epoch, checked against it.
+ fn fetch_content(
+ &self,
+ hash: [u8; 32],
+ size: u64,
+ ) -> impl Future<Output = anyhow::Result<Vec<u8>>> + Send;
/// Starts sync with every peer (e.g. after holding it back).
fn request_sync(&self);