Nixers project: Bittorrent library - Community & Forums Related Discussions

Users browsing this thread: 1 Guest(s)
josuah
Long time nixers
xkco: you rock!



Venam started to make structs to hold the metainfo. That is a good idea I think, as it will help us work on multiple parts of the code independently and merge everything easily.

Here is the proposition: if we need to have an array of complex items, use a struct. Otherwise just use variables.

We can have multiple torrents per process and do not know how many of them.
I think we need a 'torrent' struct (torrent[i]->data).

Some torrents can have multiple files, struct as well (files[i]->path).

Code:
struct file {
    size_t       length;
    char        *path;
}

Code:
struct torrent {
    char        *announce_list[];   /* array of urls             */
    char        *name;
    size_t       length;
    size_t       pieces_length;
    size_t       pieces_count;      /* for convenience           */
    char        *pieces_sha1;
    char         torrent_sha1[20];  /* to compute ourself        */
    struct file *files[];           /* is NULL for single-file   */
    char        *data;              /* pointer to mmap-ed memory */
    char        *downloaded;        /* bitmask for the parts     */
}

If there is only announce on the metainfo file, the 'announce_list' would only
hold the first (prefered) url of tracker:

Code:
torrent->announce_list = { "http://tracker-1.tld", NULL }

I do not see the need to separate metainfo from the actual data.

We could do a 'part' struct as well, to avoid implementing a bitmask, and for convenience.


Messages In This Thread
Nixers project: Bittorrent library - by z3bra - 30-07-2017, 04:40 AM
RE: New project: Bittorrent library - by r4ndom - 30-07-2017, 05:33 AM
RE: New project: Bittorrent library - by Tmplt - 30-07-2017, 07:20 AM
RE: New project: Bittorrent library - by z3bra - 30-07-2017, 07:22 AM
RE: New project: Bittorrent library - by Tmplt - 30-07-2017, 07:31 AM
RE: New project: Bittorrent library - by z3bra - 30-07-2017, 09:15 AM
RE: New project: Bittorrent library - by Tmplt - 30-07-2017, 09:45 AM
RE: New project: Bittorrent library - by z3bra - 30-07-2017, 10:42 AM
RE: New project: Bittorrent library - by z3bra - 30-07-2017, 08:45 PM
RE: New project: Bittorrent library - by venam - 31-07-2017, 12:22 AM
RE: New project: Bittorrent library - by z3bra - 31-07-2017, 03:36 AM
RE: New project: Bittorrent library - by jkl - 31-07-2017, 04:13 AM
RE: New project: Bittorrent library - by z3bra - 31-07-2017, 07:18 AM
RE: New project: Bittorrent library - by sff - 31-07-2017, 01:28 PM
RE: New project: Bittorrent library - by z3bra - 01-08-2017, 04:19 AM
RE: New project: Bittorrent library - by r4ndom - 01-08-2017, 05:31 PM
RE: New project: Bittorrent library - by z3bra - 01-08-2017, 06:19 PM
RE: New project: Bittorrent library - by z3bra - 02-08-2017, 03:53 AM
RE: New project: Bittorrent library - by r4ndom - 02-08-2017, 06:24 AM
RE: New project: Bittorrent library - by z3bra - 02-08-2017, 08:27 AM
RE: New project: Bittorrent library - by xero - 02-08-2017, 07:27 PM
RE: New project: Bittorrent library - by z3bra - 03-08-2017, 03:31 AM
RE: New project: Bittorrent library - by r4ndom - 03-08-2017, 04:57 AM
RE: New project: Bittorrent library - by z3bra - 03-08-2017, 07:59 AM
RE: New project: Bittorrent library - by josuah - 05-08-2017, 04:06 PM
RE: New project: Bittorrent library - by z3bra - 05-08-2017, 06:18 PM
RE: New project: Bittorrent library - by josuah - 05-08-2017, 07:21 PM
RE: New project: Bittorrent library - by z3bra - 06-08-2017, 07:10 AM
RE: New project: Bittorrent library - by josuah - 06-08-2017, 01:10 PM
RE: New project: Bittorrent library - by josuah - 06-08-2017, 05:00 PM
RE: New project: Bittorrent library - by z3bra - 06-08-2017, 06:40 PM
RE: New project: Bittorrent library - by josuah - 07-08-2017, 09:38 AM
RE: New project: Bittorrent library - by z3bra - 08-08-2017, 05:49 PM
RE: New project: Bittorrent library - by josuah - 11-08-2017, 05:23 PM
RE: New project: Bittorrent library - by z3bra - 12-08-2017, 03:37 AM
RE: New project: Bittorrent library - by josuah - 12-08-2017, 07:24 AM
RE: New project: Bittorrent library - by z3bra - 12-08-2017, 08:42 AM
RE: New project: Bittorrent library - by josuah - 12-08-2017, 07:06 PM
RE: New project: Bittorrent library - by nas - 24-08-2017, 11:53 AM
RE: New project: Bittorrent library - by josuah - 24-08-2017, 01:36 PM
RE: New project: Bittorrent library - by josuah - 24-08-2017, 01:42 PM
RE: New project: Bittorrent library - by nas - 25-08-2017, 02:44 AM
RE: New project: Bittorrent library - by z3bra - 25-08-2017, 10:18 AM
RE: New project: Bittorrent library - by z3bra - 26-08-2017, 03:26 AM
RE: New project: Bittorrent library - by josuah - 29-08-2017, 02:51 AM
RE: New project: Bittorrent library - by z3bra - 29-08-2017, 03:17 AM
RE: New project: Bittorrent library - by josuah - 29-08-2017, 08:16 AM
RE: New project: Bittorrent library - by z3bra - 28-09-2017, 11:53 AM
RE: New project: Bittorrent library - by z3bra - 09-10-2017, 02:36 PM
RE: New project: Bittorrent library - by josuah - 10-10-2017, 05:24 PM
RE: New project: Bittorrent library - by z3bra - 10-10-2017, 07:36 PM
RE: New project: Bittorrent library - by josuah - 28-03-2018, 05:40 PM
RE: New project: Bittorrent library - by z3bra - 03-07-2018, 11:24 AM