Making the (partial) Rust BitTorrent client more reasonable

  Рет қаралды 30,373

Jon Gjengset

Jon Gjengset

Күн бұрын

After doing the BitTorrent CodeCrafters challenge in #rustlang ( • Implementing (part of)... ), I had an urge to do some re-organization to better fit what a real implementation would look like when it has to handle files, multiple peers, multiple pieces, concurrency, etc. So, that's what we did!
If you want to give the whole challenge a try, please consider using my refrral link: app.codecrafters.io/join?via=...
0:00:00 Recap
0:11:18 Writing what we want to end up with
0:21:28 Writing the interface outside-in
0:36:56 Grabbing peer info
0:42:44 Interacting with a single peer
0:56:10 Decoding which pieces a peer has
1:34:11 Moment of hesitation
1:39:15 Ordering pieces
1:53:11 Connecting to a pool of peers
2:05:10 Grabbing pieces one by one
2:20:09 Cooperatively download all the blocks!
3:11:23 Handling choking
3:28:06 Putting together all the pieces
3:35:29 Fixing the one bug
3:45:23 The many things that remain
Stream diff: github.com/jonhoo/codecrafter...
Live version with chat: kzbin.info8sEdv0G1VIE

Пікірлер: 27
@twistedsector
@twistedsector 6 ай бұрын
Your videos are invaluable to the intermediate Rust community, Jon!
@elgusanito6991
@elgusanito6991 6 ай бұрын
nice thumbnail
@HowDoYouUseSpaceBar
@HowDoYouUseSpaceBar 6 ай бұрын
😩
@elgusanito6991
@elgusanito6991 6 ай бұрын
​@@HowDoYouUseSpaceBar😩
@sifiso3223
@sifiso3223 6 ай бұрын
1:53:13 - the thumbnail
@tjoey6663
@tjoey6663 2 ай бұрын
really fascinating stuff, hoping to see more like this
@CompletelyCovered3
@CompletelyCovered3 6 ай бұрын
A sequel to the famed classic!
@haydenridd
@haydenridd 21 күн бұрын
Thank god we replaced all those nasty single digit "8"s with a scoped constant and two nested casts
@drvanon
@drvanon 6 ай бұрын
One architecture optimization (dont really know what to call this) i would make is to have a function called download block range and have that be where you deal with all the complex logic that you dealt with in downloaded. Then download all would just call the entire range and for any specific set of files you would figure out what blocks you need. Now, becuase of the possible overlap of pieces across blocks, it is possible that you download a block multiple times in a download all. Edit: or maybe I am misunderstanding how files/pieces/blocks work.
@JakWai01
@JakWai01 6 ай бұрын
Just wanted to say thanks for having made my Rust learning experience in the past really enjoyable. Totally unrelated question, but what kind of zip neck sweater are you wearing?
@pdd9366
@pdd9366 6 ай бұрын
The thumbnail lol
@driedurchin
@driedurchin 6 ай бұрын
How would you go about testing this implementation in a robust manner? Seems difficult to create all the edge cases of disconnections, retransmissions, etc.
@illeatmyhat
@illeatmyhat 2 ай бұрын
gut feeling tells me you want property-based testing, but agreed that the unknown-unknowns can be a real headache here.
@freemasry-gr8hw
@freemasry-gr8hw 4 ай бұрын
could you make a video on implementing the Bittorrent DHT Protocol ? I would really love to see that on your channel :)
@vaporif
@vaporif 5 ай бұрын
What did you mean by referring to async_channel as smoll-rs based one? It doesn't depend on smoll-rs runtime.
@Nunya58294
@Nunya58294 4 ай бұрын
Although I don't code in Rust this is really fascinating!
@codeplay4947
@codeplay4947 5 ай бұрын
Your colorscheme/theme is really niceeeeeeeeeeeeeeee!!!!! what is it, (it's not gruvbox) i checked your config files but cannot implement the same in mine, how can i get a theme like yours....
@alphabitserial
@alphabitserial 6 ай бұрын
I'd love to see what a 'from scratch' impl would look like as opposed to using (mostly) just the crates from the Codecrafters challenges. One example I could think of is using nom for bencode instead
@julienleclercq6809
@julienleclercq6809 6 ай бұрын
Isn't nom quite slow for a production software? Always read that it was more of a quickly prototype, don't care of parsing kind of thing.
@alphabitserial
@alphabitserial 6 ай бұрын
@@julienleclercq6809 Not that I'm aware of, it's zero-copy by design and usually almost as fast as a hand-written C parser
@julienleclercq6809
@julienleclercq6809 6 ай бұрын
@@alphabitserial Ah. yes indeed, I thought this was slower than serde, but it's actually quite the opposite. Thanks for the heads up!
@alphabitserial
@alphabitserial 6 ай бұрын
@@julienleclercq6809 Absolutely!
@raidensama1511
@raidensama1511 6 ай бұрын
🥤🍿
@Dorumin
@Dorumin 6 ай бұрын
5:12 what was that voice
@simbiont777
@simbiont777 6 ай бұрын
self.offset in DownloadedIter equals to 0 and still unchanged or I missed something?
@driedurchin
@driedurchin 6 ай бұрын
Saw that too, only half-way through though.
@jonhoo
@jonhoo 6 ай бұрын
Good catch! Fixed in github.com/jonhoo/codecrafters-bittorrent-rust/commit/27aeebfb1d9ff2e9294406b332a76ef71e38f4c1. Not caught by the CI I think because CodeCrafters only has single-file download at the moment.
Crust of Rust: Iterators
1:26:27
Jon Gjengset
Рет қаралды 94 М.
programming language, speed compilation #c++ #golang #rust
0:30
Artem CYOU
Рет қаралды 295 М.
Teenagers Show Kindness by Repairing Grandmother's Old Fence #shorts
00:37
Fabiosa Best Lifehacks
Рет қаралды 46 МЛН
Тяжелые будни жены
00:46
К-Media
Рет қаралды 5 МЛН
КАКОЙ ВАШ ЛЮБИМЫЙ ЦВЕТ?😍 #game #shorts
00:17
15 crazy new JS framework features you don’t know yet
6:11
Fireship
Рет қаралды 179 М.
Dev-Log 14 | The 1st C++ Game
15:17
SAVGLab
Рет қаралды 189
3D Pixel Art Village in Godot 4
1:38
Eduardo Schildt
Рет қаралды 139 М.
Pirating this game will RUIN YOUR CAREER
0:20
GAMESPICY
Рет қаралды 556 М.
Is A Stacked Monitor Setup Worth It? #setup
0:16
MobilePixels Official
Рет қаралды 70 М.
Phosgene.exe Trojan (Skid)
6:56
Awesome Tu boi
Рет қаралды 209
Crust of Rust: std::collections
2:45:04
Jon Gjengset
Рет қаралды 65 М.
Crust of Rust: Functions, Closures, and Their Traits
1:06:40
Jon Gjengset
Рет қаралды 83 М.
Longest Consecutive Sequence - Leetcode 128 - Python3
7:54
LeetCode with Don
Рет қаралды 25
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 1,9 МЛН
Nokia 3310 versus Red Hot Ball
0:37
PressTube
Рет қаралды 3,4 МЛН
What’s your charging level??
0:14
Татьяна Дука
Рет қаралды 7 МЛН
The power button can never be pressed!!
0:57
Maker Y
Рет қаралды 52 МЛН