Our Personal Data Server from scratch!
0

Configure Feed

Select the types of activity you want to include in your feed.

ripple: anti-entropy gossip sync

Lewis: May this revision serve well! <lu5a@proton.me>

author
Lewis
committer
Tangled
date (Jun 14, 2026, 6:46 PM +0300) commit e13ba7f4 parent a3f729c3 change-id vprmptyy
+26
+26
crates/tranquil-ripple/src/gossip.rs
··· 4 4 use crate::metrics; 5 5 use crate::transport::{ChannelTag, IncomingFrame, Transport}; 6 6 use foca::{Config, Foca, Notification, Runtime, Timer}; 7 + use rand::Rng; 7 8 use rand::SeedableRng; 8 9 use rand::rngs::StdRng; 9 10 use std::collections::HashSet; ··· 187 188 let (timer_tx, mut timer_rx) = mpsc::channel::<(Timer<PeerId>, Duration)>(256); 188 189 189 190 const WATERMARK_STALE_SECS: u64 = 30; 191 + const ANTI_ENTROPY_SECS: u64 = 30; 190 192 191 193 tokio::spawn(async move { 192 194 let mut runtime = BufferedRuntime::new(); ··· 215 217 216 218 let mut gossip_tick = tokio::time::interval(Duration::from_millis(gossip_interval_ms)); 217 219 gossip_tick.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip); 220 + 221 + let mut anti_entropy_tick = 222 + tokio::time::interval(Duration::from_secs(ANTI_ENTROPY_SECS)); 223 + anti_entropy_tick.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip); 224 + let mut ae_rng = StdRng::from_os_rng(); 218 225 219 226 loop { 220 227 tokio::select! { ··· 339 346 rate_limit_bytes = store.rate_limit_estimated_bytes(), 340 347 "gossip health check" 341 348 ); 349 + } 350 + _ = anti_entropy_tick.tick() => { 351 + let peers: Vec<SocketAddr> = members.active_peers().collect(); 352 + if !peers.is_empty() { 353 + let snapshot = store.peek_full_state(); 354 + if !snapshot.is_empty() { 355 + let peer = peers[ae_rng.random_range(0..peers.len())]; 356 + chunk_and_serialize(&snapshot).into_iter().for_each(|chunk| { 357 + let t = transport.clone(); 358 + let c = shutdown.clone(); 359 + tokio::spawn(async move { 360 + tokio::select! { 361 + _ = c.cancelled() => {} 362 + _ = t.send(peer, ChannelTag::CrdtSync, &chunk) => {} 363 + } 364 + }); 365 + }); 366 + } 367 + } 342 368 } 343 369 } 344 370 }