Skip to main content

tree_diff

Function tree_diff 

Source
pub async fn tree_diff<S: Store>(
    tree: &HashTree<S>,
    old_root: Option<&Cid>,
    new_root: &Cid,
    concurrency: usize,
) -> Result<TreeDiff, HashTreeError>
Expand description

Compute diff between two trees

Returns hashes present in new_root but not in old_root. Uses subtree pruning: when a hash exists in old tree, skips entire subtree.

§Algorithm

  1. Collect all hashes from old tree into a set
  2. Walk new tree:
    • If hash in old set: skip (subtree unchanged)
    • If hash not in old set: add to result, traverse children

§Arguments

  • tree - HashTree instance
  • old_root - Root of the old tree (may be None for first push)
  • new_root - Root of the new tree
  • concurrency - Number of concurrent fetches

§Returns

TreeDiff with added hashes and statistics