Find all changes that would need to be unrecorded to safely remove a change. This includes the target change plus any dependents (in topological order). # Arguments `txn` - Read transaction `view` - View to analyze `hash` - Hash of the change to unrecord `max_depth` - Maximum cascade depth # Returns A vector of hashes in the order they should be unrecorded (dependents first).
(
txn: &T,
view: &ViewState,
hash: &Hash,
max_depth: Option<usize>,
)
| 502 | /// |
| 503 | /// A vector of hashes in the order they should be unrecorded (dependents first). |
| 504 | pub fn find_unrecord_set<T: ViewTxnT>( |
| 505 | txn: &T, |
| 506 | view: &ViewState, |
| 507 | hash: &Hash, |
| 508 | max_depth: Option<usize>, |
| 509 | ) -> UnrecordResult<Vec<Hash>> { |
| 510 | let max_depth = max_depth.unwrap_or(100); |
| 511 | let mut result = Vec::new(); |
| 512 | let mut visited = HashSet::new(); |
| 513 | let mut to_process = vec![(*hash, 0)]; |
| 514 | |
| 515 | while let Some((current_hash, depth)) = to_process.pop() { |
| 516 | if depth > max_depth { |
| 517 | return Err(UnrecordError::Inconsistent { |
| 518 | reason: format!("Cascade depth exceeded maximum of {}", max_depth), |
| 519 | }); |
| 520 | } |
| 521 | |
| 522 | if visited.contains(¤t_hash) { |
| 523 | continue; |
| 524 | } |
| 525 | visited.insert(current_hash); |
| 526 | |
| 527 | // Get internal ID |
| 528 | let node_id = match txn.get_internal(¤t_hash) { |
| 529 | Ok(Some(id)) => id, |
| 530 | Ok(None) => continue, |
| 531 | Err(e) => return Err(UnrecordError::Database(e.to_string())), |
| 532 | }; |
| 533 | |
| 534 | // Check if in view |
| 535 | if txn |
| 536 | .get_change_seq(view, node_id) |
| 537 | .map_err(|e| UnrecordError::Database(e.to_string()))? |
| 538 | .is_none() |
| 539 | { |
| 540 | continue; |
| 541 | } |
| 542 | |
| 543 | result.push(current_hash); |
| 544 | |
| 545 | // Note: Finding dependents requires traversing all changes |
| 546 | // In a full implementation, we'd use the rev_deps table |
| 547 | } |
| 548 | |
| 549 | // Reverse so dependents come first |
| 550 | result.reverse(); |
| 551 | |
| 552 | Ok(result) |
| 553 | } |
| 554 | |
| 555 | /// Compute the new Merkle state after unrecording changes. |
| 556 | /// |
no test coverage detected