Skip to content

Commit

Permalink
add documentation for differences between kubo and iroh
Browse files Browse the repository at this point in the history
  • Loading branch information
ramfox committed Aug 31, 2022
1 parent 2747871 commit e4555ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion iroh-resolver/src/balanced_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,16 @@ fn create_unixfs_node_from_links(links: Vec<(Cid, u64)>) -> Result<UnixfsNode> {
.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();
Expand Down Expand Up @@ -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()?;
Expand Down

0 comments on commit e4555ba

Please sign in to comment.