Push new log entries to peers on commit

A broadcast channel forwards each freshly committed entry straight to
connected peers, so a registration propagates in milliseconds. The
periodic digest drops to a 10s anti-entropy backstop.
This commit is contained in:
Jean Chevronnet 2026-07-12 07:20:25 +00:00
parent d0556ebe8c
commit df7b413862
No known key found for this signature in database
3 changed files with 101 additions and 25 deletions

View file

@ -40,13 +40,15 @@ async fn main() -> Result<()> {
guest_nick: cfg.server.guest_nick.clone(),
guest_seq: (ts % 100_000) as u32,
})];
let (gossip_tx, _) = tokio::sync::broadcast::channel::<engine::db::LogEntry>(1024);
let mut db = engine::db::Db::open("fedserv.db.jsonl", &cfg.server.sid);
db.scram_iterations = cfg.server.scram_iterations;
db.set_outbound(gossip_tx.clone());
let engine = Arc::new(Mutex::new(Engine::new(services, db)));
if let Some(gossip) = cfg.gossip.clone() {
tracing::info!(peers = cfg.peer.len(), "starting gossip");
tokio::spawn(gossip::run(engine.clone(), gossip, cfg.peer.clone(), cfg.server.sid.clone()));
tokio::spawn(gossip::run(engine.clone(), gossip, cfg.peer.clone(), cfg.server.sid.clone(), gossip_tx));
}
let addr = format!("{}:{}", cfg.uplink.host, cfg.uplink.port);