Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica

collect_missing_ancestors

Function collect_missing_ancestors 

Source
pub async fn collect_missing_ancestors(
    backend: &dyn BackendImpl,
    entry_ids: &[ID],
) -> Result<Vec<ID>>
Expand description

Collect all missing ancestors for given entry IDs using DAG traversal.

This function performs a breadth-first traversal of the DAG to find all entries that are referenced but not present locally. It’s used when receiving tips from a peer to determine what entries need to be fetched.

§Algorithm Complexity

  • Time: O(V + E) where V is the number of visited entries and E is the number of parent relationships
  • Space: O(V) for the visited set and queue storage

§Arguments

  • backend - Database backend to check for entry existence
  • entry_ids - Starting entry IDs to traverse from

§Returns

Vec of entry IDs that are missing from the local database

§Example

use eidetica::sync::utils::collect_missing_ancestors;
use eidetica::backend::database::InMemory;

let backend = InMemory::new();
let missing_ids = vec![ID::from("tip1"), ID::from("tip2")];
let missing = collect_missing_ancestors(&backend, &missing_ids).await?;
// Returns IDs of entries that need to be fetched from peer