Collect all dependencies needed to insert a change. This recursively collects all transitive dependencies. # Arguments `txn` - Read transaction `change` - The change to collect dependencies for `available` - Set of available change hashes `max_depth` - Maximum recursion depth # Returns Set of all dependency hashes needed (not including those already applied).
(
txn: &T,
change: &Change,
available: &HashSet<Hash>,
max_depth: usize,
)
| 478 | /// |
| 479 | /// Set of all dependency hashes needed (not including those already applied). |
| 480 | pub fn collect_all_dependencies<T: GraphTxnT>( |
| 481 | txn: &T, |
| 482 | change: &Change, |
| 483 | available: &HashSet<Hash>, |
| 484 | max_depth: usize, |
| 485 | ) -> InsertResult<HashSet<Hash>> { |
| 486 | let mut needed = HashSet::new(); |
| 487 | let mut queue: VecDeque<(Hash, usize)> = VecDeque::new(); |
| 488 | let mut visited = HashSet::new(); |
| 489 | |
| 490 | // Start with direct dependencies |
| 491 | for dep in change.dependencies() { |
| 492 | if !visited.contains(dep) { |
| 493 | queue.push_back((*dep, 0)); |
| 494 | visited.insert(*dep); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | while let Some((hash, depth)) = queue.pop_front() { |
| 499 | if depth > max_depth { |
| 500 | return Err(InsertError::CyclicDependency { |
| 501 | message: format!("Maximum dependency depth {} exceeded", max_depth), |
| 502 | }); |
| 503 | } |
| 504 | |
| 505 | // Check if already in repository |
| 506 | if txn |
| 507 | .get_internal(&hash) |
| 508 | .map_err(|e| InsertError::Database(e.to_string()))? |
| 509 | .is_some() |
| 510 | { |
| 511 | continue; |
| 512 | } |
| 513 | |
| 514 | // Check if available |
| 515 | if available.contains(&hash) { |
| 516 | needed.insert(hash); |
| 517 | // Note: We'd need the actual change content to recurse further |
| 518 | // For now, we assume available changes have their deps satisfied |
| 519 | } else { |
| 520 | needed.insert(hash); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | Ok(needed) |
| 525 | } |
nothing calls this directly
no test coverage detected