summaryrefslogtreecommitdiffstats
path: root/src/remake/switch.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-24 18:18:29 +0200
committertv <tv@krebsco.de>2026-10-24 18:18:29 +0200
commit09f2dfd083c4fcdce4c5ca7376353906eb025c42 (patch)
treee13141f10e3854408bd70d18d1bf31581abe5458 /src/remake/switch.rs
parent371e52cb48bae99232547f6fae6a0487a85c2d04 (diff)
put remake content into blobs
Diffstat (limited to 'src/remake/switch.rs')
-rw-r--r--src/remake/switch.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/remake/switch.rs b/src/remake/switch.rs
index e9f49ee..c18905c 100644
--- a/src/remake/switch.rs
+++ b/src/remake/switch.rs
@@ -26,6 +26,7 @@ use tracing::{error, info, warn};
use super::Host;
use super::catchup;
+use super::content;
use super::delta::{self, ReplayStats};
use super::kind::Translator;
use super::local::LocalStatus;
@@ -82,6 +83,12 @@ async fn check<H: Host>(host: &H) {
vote::cast(host).await;
let all = host.read_doc(records::load_all).await;
+ content::prune(
+ host,
+ &all,
+ unix_millis(),
+ host.dormant_after().as_millis() as u64,
+ );
let local_record = EpochRecord::from(local);
let committed: Vec<(String, Record)> = all
@@ -157,10 +164,16 @@ async fn switch<H: Host>(
id: &str,
record: &Record,
) -> Result<(ReplayStats, Option<String>), String> {
- let (Some(expected), Some(request)) = (record.committed_epoch(), record.snapshot_request(id))
+ let (Some(expected), Some(mut request)) =
+ (record.committed_epoch(), record.snapshot_request(id))
else {
return Err("unreadable remake record".to_owned());
};
+ // Voters fetched it already; a node that didn't vote fetches it now. Without it the
+ // switch fails, and the node rejoins (downloading the snapshot instead).
+ if let Some(reference) = &record.proposal.content {
+ request.content = Some(content::ensure(host, reference).await?);
+ }
let translator = request
.translator()
.ok_or_else(|| format!("unknown remake kind {:?}", request.kind))?;