Nixers project: Bittorrent library - Community & Forums Related Discussions
Users browsing this thread: 11 Guest(s)
|
|||
(06-08-2017, 07:10 AM)z3bra Wrote: As for the prefixes, I settled on simply 'b' for bencoding related function Perfect :) (06-08-2017, 07:10 AM)z3bra Wrote: to include them in the repo Maybe some could be turned into tests. It may be a bit early to think about it, but this came on its own while reading about bittorrent. Once we start to transfer data from a peer, how do we store it? Here is a prososition: An approach is to store the parts into files and directories: Parts gets downloaded to a memory buffer, and once one is complete, it gets saved to the disk as <hash of torrent>/<hash of the part>: Code: |-- 2072a695613e5103d9ac03c2885c5e2656cb5ff0 # hash of the torrent #1 Advantages:
Disadvantage:
To overcome this, it would be possible to store every single part in an unique dir for all the torrents, but then, race condition could occur: if two process/threads download the same part at the same time, the first one write it to the disk. Instead, before starting a download, a worker could seek in the parts directories of the other torrent if it can find the existing part. I would go to the simplest way, with one directory per torrent, which still permit optimizations. [EDIT] torrent != parts of a torrent |
|||