Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torrent's pieces live updates #37

Open
kilork opened this issue Apr 7, 2020 · 0 comments
Open

Torrent's pieces live updates #37

kilork opened this issue Apr 7, 2020 · 0 comments
Labels

Comments

@kilork
Copy link
Owner

kilork commented Apr 7, 2020

GET /api/torrent/{id}/piece/stream

We use Server-Sent Events. Each update comes as patch to previous state. Initial state received with GET /api/torrent/{id}/piece call.

Variant 1

Text message with base64 encoded state.

Variant 2

Each message has left attribute, which says how much pieces still not downloaded. Next is sorted array "hunks". patch is map with fields "off" and array of bytes, each represents 8 pieces.

Example:

Initial state: [1, 0, 0, 128] or in other words: we have two pieces with indexes 7 and 24. We have in total 30 pieces and 28 left to download.

{"left":25,"hunks":[{"off":0,"bits":[129,128]},{"off":3,"bits":[192]}]}

Updated state would be [129, 128, 0, 192], we downloaded yet 3 more pieces and we have 25 pieces to downloaded. Maintaining this balance can help frontend to identify desynchronization and rerequest state.

Looks like probably this is not we need exactly, because size of hunks can easely overcome such of just plain state. So we would now implement Variant 1, just it is much simplier.

@kilork kilork added the api label Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant