Unixfs and the 1MB block limit

My understanding is that blocks are limited to 1MB (to prevent a DoS attack). How are unixfs links larger than 1MB handled? For example, what if a link of type directory has so many sub-links that the overall size exceeds 1MB? Or what if a file is so large that the corresponding link of type file exceeds 1MB (because it points to the too many blocks that make up the file)?

This was an issue for a long time that was solved by directory sharding. Directory entries can be sharded into multiple separate nodes that all are smaller than 1MB.

By default node can read but won’t produce sharded directories. This behaviour can be changed with ipfs config --json Experimental.ShardingEnabled true.

@JustinDrake are you asking about chunking? By default ipfs divides files into chunks that are about 256kb and builds a merkle dag representing how to reassemble the original file from those chunks. There’s a tutorial about it here:

https://dweb-primer.ipfs.io/ipfs-dag/lessons/files-as-dags.html