diff --git a/iroh-resolver/src/balanced_tree.rs b/iroh-resolver/src/balanced_tree.rs index 6f5ed05850..32dbacab56 100644 --- a/iroh-resolver/src/balanced_tree.rs +++ b/iroh-resolver/src/balanced_tree.rs @@ -138,7 +138,16 @@ fn create_unixfs_node_from_links(links: Vec<(Cid, u64)>) -> Result { .into_iter() .map(|(cid, len)| dag_pb::PbLink { hash: Some(cid.to_bytes()), + /// ALL "stem" nodes have `name: None`. + /// In kubo, nodes that have links to `leaf` nodes have `name: Some("".to_string())` name: None, + /// tsize has no strict definition + /// Iroh's definiton of `tsize` is "the cumulative size of the encoded tree + /// pointed to by this link", so not just the size of the raw content, but including + /// all encoded dag nodes as well. + /// In the `go-merkledag` package, the `merkledag.proto` file, states that tsize + /// is the "cumulative size of the target object" + /// (https://github.com/ipfs/go-merkledag/blob/8335efd4765ed5a512baa7e522c3552d067cf966/pb/merkledag.proto#L29) tsize: Some(len as u64), }) .collect(); @@ -174,7 +183,6 @@ impl TreeNode { Ok((cid, bytes, len as u64)) } TreeNode::Stem(links) => { - // keep track of `tsize`, aka the size of the encoded tree at the given link let mut cumulative_len: u64 = links.iter().map(|(_, len)| len).sum(); let node = create_unixfs_node_from_links(links)?; let (cid, bytes) = node.encode()?;