🌟 adding Torrent support to IPFS #779
Description
I've started working in enabling Torrent support for js-ipfs, very much in the same way that we have support for: dag-pb, dag-cbor, eth-blocks, eth-tx, zcash (go-ipfs only), git (go-ipfs only) and bitcoin (go-ipfs only).
The end goal is to expose two top level commands to add and retrieve files that are Torrents, from the IPFS or BitTorrent network (through a bridge and in the future, by connecting directly). The commands being:
- jsipfs torrent add
- jsipfs torrent cat
However, I stumbled upon a question in which we will have to make a decision and I would like to get feedback before going at full speed. In BitTorrent, torrent files are not referenced by a Cryptographic hash due to their ephemeral and mutable nature (in fact, decoding and encoding is not even always idempotent by spec), the only thing that has a cryptographic identifier is the info
field in the torrent file.
I started implementing the IPLD format for a Torrent file, but I'm guessing that most people will want to fetch their torrent through the infoHash of the torrent that they get from a thing like a magnetic URI, the crux is that there is never a file for the info
field, as soon as a infoHash query is performed, a Torrent file is retried, rising the question of:
Should dag.get(<infoHash>/somePath)
resolve through the retrieved Torrent file or only over the info field?
- Resolve through the Torrent file - This is weird to the IPLD resolver, as it would be resolving an immutable pointer to something that has more fields
- Resolve only within the info field - This would force us to make the
info
field a full standalone object that can be transferred independently (the solution I'm leaning towards). This option would result in two multicodecs for Torrents,torrent-file
andtorrent-info
.
Thoughts? //cc @jbenet @whyrusleeping @nicola