MCPcopy Create free account
hub / github.com/ceramicnetwork/rust-ceramic / expiry

Method expiry

p2p/src/node.rs:380–404  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

378 }
379
380 fn expiry(&mut self) -> Result<()> {
381 // Cleanup bitswap sessions
382 let mut to_remove = Vec::new();
383 for (session_id, workers) in &mut self.bitswap_sessions {
384 // Check if the workers are still active
385 workers.retain(|(_, worker)| !worker.is_finished());
386
387 if workers.is_empty() {
388 to_remove.push(*session_id);
389 }
390
391 // Only do a small chunk of cleanup on each iteration
392 // TODO(arqu): magic number
393 if to_remove.len() >= 10 {
394 break;
395 }
396 }
397
398 for session_id in to_remove {
399 let (s, _r) = oneshot::channel();
400 self.destroy_session(session_id, s);
401 }
402
403 Ok(())
404 }
405
406 /// Subscribe to [`NetworkEvent`]s.
407 #[tracing::instrument(skip(self))]

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
destroy_sessionMethod · 0.80
channelFunction · 0.50
is_emptyMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected