Comments (8)
The reference implementation is correct. Please file an issue with libtorrent.
from bittorrent.org.
a related issue that came up is that the exact algorithm for adding pad-files is not specified in BEP52, but it's important when creating hybrid torrents.
At least the way libtorrent works is, when parsing a hybrid torrent, it builds up the file layout for a the v2 torrent while parsing the files tree
, it then parses the v1 files and assumes pad files will be added the same way they are added in the v2 parsing. If they end up with different file layouts, the torrent is rejected.
Algorithm
As far as I can tell, there are two main approaches:
- Pad files are added in-front of files, if the current size is not aligned
- Pad files are added after files, if the current size is not aligned (to prepare for the next file to be aligned)
(2) will end up with "tail-padding", where the last file of the torrent is a pad file, which is redundant. I noticed the reference torrent creator does this. libtorrent does (1) and won't add tail-padding.
Since libtorrent has already been released with behavior (1), I think going forward I will just have to make the torrent loading accept both. i.e. consider the v1 files compatible both with and without tail padding.
Empty files
The other aspect this affects is whether empty files have padding in-front of them or after them. This is a bit trickier to support both of, since it affects the file indices. Although, it doesn't affect piece indices, or the piece -> file mapping, so maybe it's not unreasonable to be forgiving on this choice either.
@the8472 @ssiloti do you have opinions? should this be specified or should it be considered "quality of implementation" how to interpret valid hybrid torrents?
from bittorrent.org.
BEP52 says "Padding files are synthetic files inserted into the file list to let the following file start at a piece boundary." which does suggest approach (2).
from bittorrent.org.
if the last file is an empty file, there won't be any tail-padding with algorithm (2).
from bittorrent.org.
Why would empty files need any padding? They don't change the alignment.
from bittorrent.org.
they don't. The reference implementation adds padding to make empty files aligned to pieces too, which I believe is unnecessary.
e.g.
file1
empty1
empty2
are padded like:
file1
.pad
empty1
empty2
where technically there doesn't need to be a pad file at all
from bittorrent.org.
I don't think it matters that much exactly how the padding is applied, but I hadn't appreciated that it's kind of important to agree on the details to make hybrid torrents have their v1 file layout match the v2 layout.
from bittorrent.org.
As another data point BiglyBT creates hybrid torrents so that every file starts at a piece boundary, which means it adds padding before empty files, but it omits padding after the last file.
So
file1
empy1
empty2
is encoded as
file1
<padding>
empty1
empty2
and
file1
empty1
empty2
file2
is encoded as
file1
<padding>
empty1
empty2
file2
.
from bittorrent.org.
Related Issues (20)
- [Proposal] BEP56: Data compression extension HOT 17
- BEP47 symbolic links to directories HOT 4
- Can the bep52 spec clearly explain what happens with non-powers of two. HOT 8
- Synthetic migration torrents HOT 8
- https://www.bittorrent.org is offline HOT 4
- Is BitTorrent an Open Source Protocol? HOT 3
- Connect
- hop.code-workspace.txt
- faq: nostr and bittorrent? HOT 2
- Question: The reasonings of the UDP6 `IP address` field (BEP-15)
- Adopt DNSLink for mapping domains to torrents
- Proposal: Git Integration HOT 1
- Proposal: HTTP and TCP Tunneling HOT 4
- [Proposal] Passwordless authentication with Bittorrent?
- BEP: Extensions supported by tracker HOT 14
- Wrong ed25519 keys? HOT 9
- BEP Proposal: TLS HOT 1
- Post Quantum Cryptography Support HOT 1
- Predefined directories: Allowing bittorrent to easily be adopted with other applications HOT 4
- BEP 15 Magic Constant HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bittorrent.org.