casey / casey/annotated-torrents

RFC 1: Metadata Format

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Description

We'll need to choose a format for storing metadata.

I think the major choice to be made is whether to use a binary format or a text-based format. A binary format will be simpler to encode and decode and more space efficient, however users will not be able to read or write encoded files directly.

Text format encoders are more complicated and less space efficient, particularly for binary data, however users will be able to read and write encoded files directly.

The two formats which I think are most promising are [bencoding](https://en.wikipedia.org/wiki/Bencode), a binary format, and [YAML](https://en.wikipedia.org/wiki/YAML), a text format.

## bencoding

Bencoding is a binary format that can store arbitrary byte strings without encoding overhead. Like JSON, and unlike ProtoBufs, an external schema is not required to decode a bencoded message.

`.torrent` files are bencoded, as well as tracker responses, and [Mainline DHT](https://en.wikipedia.org/wiki/Mainline_DHT) RPC messages.

Integers, byte-strings, lists, and dictionaries are natively supported.

I think bencoding's primary advantages is that it is already commonly used in bittorrent, is extremely simple, and is a binary encoding format, so it can contain raw binary data without encoding overhead.

One disadvantage is that it is not human readable or writable, so tools must be written which can read and write bencoded metadata files.

## YAML

YAML is a text-based format. I prefer it to JSON because it is extremely readable. And, once you know how it works, it is very easy to write as well. However, it is far more complicated than JSON.

The primary advantage of YAML is that humans will be able to read and write YAML directly. So, for example, if you need to make a quick change to a metadata file, you can do it directly with a text editor instead of using a tool.

The primary disadvantage of YAML is that it is insanely complicated, although it is popular enough that libraries exist in all major languages.

## bencoding + YAML

One idea is to use bencoding as the primary format, but write simple tools that allow converting to and from YAML, so when humans need to author metadata files directly, they can dump them to YAML, edit them, and convert back to a bencoded file.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the two candidate metadata formats described in the issue: bencoding and YAML. Determine which format, or combination, should be used for metadata storage and record the decision along with its implications for human editing and binary data.

Written by the indexing model from the issue text.

Assessment

Tech stack
yaml
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.